Static Member Data - CSharp Custom Type

CSharp examples for Custom Type:static

Introduction

Static data is unique for each closed type:

class Bob<T> { public static int Count; }
                                                                                                    
class Test                                                                                     
{                                                                                              
  static void Main()                                                                           
  {
    Console.WriteLine (++Bob<int>.Count);     // 1                                             

    Console.WriteLine (++Bob<int>.Count);     // 2
    Console.WriteLine (++Bob<string>.Count);  // 1
    Console.WriteLine (++Bob<object>.Count);  // 1
  }
}

Related Tutorials