ProblemBook.NET
  • ProblemBook.NET
  • LANGS
  • Задачник.NET
    • Math
      • «AugmentedAssignment» (Задача)
      • «Rounding1» (Задача)
      • «Overflow» (Решение)
      • «Overflow» (Задача)
      • «DivideByZero» (Решение)
      • «DivideByZero» (Задача)
      • «Eps» (Решение)
      • «DynamicIncrement» (Решение)
      • «Eps» (Задача)
      • «DynamicIncrement» (Задача)
      • «Rounding2» (Решение)
      • «AugmentedAssignment» (Решение)
      • «Rounding1» (Решение)
      • «Rounding2» (Задача)
    • Oop
      • «InheritanceNestedClass» (Задача)
      • «OverloadResolutionBasic» (Решение)
      • «OverloadResolutionOverride» (Решение)
      • «OverloadResolutionBasic» (Задача)
      • «OverloadResolutionOverride» (Задача)
      • «OverloadResolutionInheritance» (Решение)
      • «OverloadResolutionInheritance» (Задача)
      • «StaticFieldInGenericType» (Решение)
      • «StaticFieldInGenericType» (Задача)
      • «InheritanceNestedClass» (Решение)
    • ValueTypes
      • «Enumerator» (Решение)
      • «MutableProperty» (Задача)
      • «Enumerator» (Задача)
      • «StructLayout» (Решение)
      • «StructLayout» (Задача)
      • «Boxing» (Решение)
      • «Boxing» (Задача)
      • «MutableProperty» (Решение)
    • Strings
      • «InternmentAndMetadata» (Решение)
      • «CorruptedNumber» (Решение)
      • «InternmentAndMetadata» (Задача)
      • «TextElementEnumerator» (Решение)
      • «CorruptedNumber» (Задача)
      • «CaseInComparison» (Решение)
      • «TextElementEnumerator» (Задача)
      • «CaseInComparison» (Задача)
      • «StableSorting» (Решение)
      • «Secure» (Решение)
      • «CurrentCulture» (Решение)
      • «StableSorting» (Задача)
      • «Secure» (Задача)
      • «StringPlusNull» (Решение)
      • «CurrentCulture» (Задача)
      • «ExplicitlyInternment» (Решение)
      • «PlusChar» (Решение)
      • «StringPlusNull» (Задача)
      • «ExplicitlyInternment» (Задача)
      • «PlusChar» (Задача)
      • «NoStringInterning» (Решение)
      • «CorruptedString» (Решение)
      • «PlusString» (Решение)
      • «CompareToVsEquals» (Решение)
      • «NoStringInterning» (Задача)
      • «PlusString» (Задача)
      • «CorruptedString» (Задача)
      • «CompareToVsEquals» (Задача)
    • Linq
      • «QueryAfterRemove» (Решение)
      • «ClosureAndVariable» (Решение)
      • «QueryAfterRemove» (Задача)
      • «ClosureAndVariable» (Задача)
      • «EnumerableToArray» (Решение)
      • «QueryWithInc» (Решение)
      • «EnumerableToArray» (Задача)
      • «QueryWithInc» (Задача)
      • «LifeAfterYield» (Решение)
      • “YieldExceptionYield” (Решение)
      • «LifeAfterYield» (Задача)
      • «ExceptionYieldYield» (Решение)
      • «ClosureAndForeach» (Решение)
      • «TryYieldFinally» (Задача)
      • «ClosureAndFor» (Решение)
      • «ExceptionYieldYield» (Задача)
      • «YieldExceptionYield» (Решение)
      • «ClosureAndForeach» (Задача)
      • «ClosureAndFor» (Задача)
      • «YieldExceptionYield» (Задача)
    • Multithreading
      • «ThreadStaticVariable» (Решение)
      • «ThreadStaticVariable» (Задача)
      • «LockSlimInFinalizer» (Решение)
      • «LockSlimInFinalizer» (Задача)
    • Summary
    • Введение
  • ProblemBook.NET
    • Oop
      • “OverloadResolutionInheritance” (Solution)
      • “InheritanceNestedClass” (Solution)
      • “OverloadResolutionInheritance” (Problem)
      • “InheritanceNestedClass” (Problem)
      • “OverloadResolutionOverride” (Solution)
      • “OverloadResolutionOverride” (Problem)
      • “StaticFieldInGenericType” (Solution)
      • “OverloadResolutionBasic” (Solution)
      • “StaticFieldInGenericType” (Problem)
      • “OverloadResolutionBasic” (Problem)
    • Strings
      • “CorruptedNumber” (Problem)
      • “PlusString” (Solution)
      • “TextElementEnumerator” (Problem)
      • “PlusString” (Problem)
      • “StableSorting” (Solution)
      • “StableSorting” (Problem)
      • “CaseInComparison” (Solution)
      • “CaseInComparison” (Problem)
      • “NoStringInterning” (Solution)
      • “Secure” (Solution)
      • “CorruptedString” (Solution)
      • “CompareToVsEquals” (Solution)
      • “CurrentCulture” (Solution)
      • “NoStringInterning” (Problem)
      • “Secure” (Problem)
      • “CorruptedString” (Problem)
      • “CompareToVsEquals” (Problem)
      • “StringPlusNull” (Solution)
      • “CurrentCulture” (Problem)
      • “ExplicitlyInternment” (Solution)
      • “PlusChar” (Solution)
      • “InternmentAndMetadata” (Solution)
      • “CorruptedNumber” (Solution)
      • “StringPlusNull” (Problem)
      • “ExplicitlyInternment” (Problem)
      • “PlusChar” (Problem)
      • “InternmentAndMetadata” (Problem)
      • “TextElementEnumerator” (Solution)
    • Linq
      • “YieldExceptionYield” (Problem)
      • “QueryAfterRemove” (Problem)
      • “ClosureAndVariable” (Problem)
      • “QueryWithInc” (Solution)
      • “QueryWithInc” (Problem)
      • “LifeAfterYield” (Solution)
      • “LifeAfterYield” (Problem)
      • “EnumerableToArray” (Solution)
      • “EnumerableToArray” (Problem)
      • «YieldExceptionYield» (Solution)
      • “ExceptionYieldYield” (Solution)
      • “ClosureAndForeach” (Solution)
      • “TryYieldFinally” (Problem)
      • “ClosureAndFor” (Solution)
      • “ExceptionYieldYield” (Problem)
      • “YieldExceptionYield” (Solution)
      • “ClosureAndForeach” (Problem)
      • “ClosureAndVariable” (Solution)
      • “QueryAfterRemove” (Solution)
      • “ClosureAndFor” (Problem)
    • Multithreading
      • “ThreadStaticVariable” (Solution)
      • “LockSlimInFinalizer” (Solution)
      • “ThreadStaticVariable” (Problem)
      • “LockSlimInFinalizer” (Problem)
    • ValueTypes
      • “StructLayout” (Problem)
      • “MutableProperty” (Solution)
      • “Boxing” (Solution)
      • “MutableProperty” (Problem)
      • “Boxing” (Problem)
      • “Enumerator” (Solution)
      • “Enumerator” (Problem)
      • “StructLayout” (Solution)
    • Math
      • “Rounding2” (Solution)
      • “AugmentedAssignment” (Solution)
      • “Rounding1” (Solution)
      • “Rounding2” (Problem)
      • “Rounding1” (Problem)
      • “AugmentedAssignment” (Problem)
      • “DivideByZero” (Solution)
      • “DivideByZero” (Problem)
      • “DynamicIncrement” (Solution)
      • “DynamicIncrement” (Problem)
      • “Eps” (Solution)
      • “Eps” (Problem)
      • “Overflow” (Solution)
      • “Overflow” (Problem)
    • Summary
    • Introduction
  • Attribution-NonCommercial-NoDerivatives 4.0 International
Powered by GitBook
On this page
  • Answer
  • Explanation
  • Links

Was this helpful?

  1. ProblemBook.NET
  2. Oop

“StaticFieldInGenericType” (Solution)

Previous“OverloadResolutionOverride” (Problem)Next“OverloadResolutionBasic” (Solution)

Last updated 6 years ago

Was this helpful?

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
ReSharper wiki: Static field in generic type
Problem