# “StaticFieldInGenericType” (Solution)

## Answer

```
0
```

## Explanation

The `Foo<int>` and `Foo<double>` are two different classes. Each of them has own static `Bar` field.

*CSharp Language Specification 5.0, 10.5.1:*

> “When a field declaration includes a static modifier, the fields introduced by the declaration are static fields. When no static modifier is present, the fields introduced by the declaration are instance fields. Static fields and instance fields are two of the several kinds of variables (§5) supported by C#, and at times they are referred to as static variables and instance variables, respectively. A static field is not part of a specific instance; instead, it is shared amongst all instances of a closed type (§4.4.2). No matter how many instances of a closed class type are created, there is only ever one copy of a static field for the associated application domain.”

## Links

* [Microsoft Code Analysis for Managed Code Warnings, CA1000](https://msdn.microsoft.com/library/ms182139.aspx)
* [ReSharper wiki: Static field in generic type](https://confluence.jetbrains.com/display/ReSharper/Static+field+in+generic+type)

[Problem](/problembookdotnet/en/oop/staticfieldingenerictype-p.md)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://andreyakinshin.gitbook.io/problembookdotnet/en/oop/staticfieldingenerictype-s.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
