Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@devlights
Created April 21, 2015 03:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devlights/2d006dd93c22ced88585 to your computer and use it in GitHub Desktop.
Save devlights/2d006dd93c22ced88585 to your computer and use it in GitHub Desktop.
ジェネリッククラスに定義したstaticフィールドは型パラメータ毎に定義される。
void Main()
{
AClass<int>.Count.Dump();
AClass<string>.Count.Dump();
AClass<int>.Count++;
AClass<int>.Count.Dump();
AClass<string>.Count.Dump();
//
// 結果:
// 0
// 0
// 1
// 0
//
}
// Define other methods and classes here
public class AClass<T>
{
public static int Count = 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment