Sunday, December 11, 2011

Designing a class 3: Shared or Static members

Often, some data or operations are not related to a specific instance. Instead they are related to the class itself. These data and operations are common to all instances. These members are called as Static members or Shared members.

Keyword used to define a member as static or shared.

[VB] Shared

[CS] static


Code Sample:

public class Employee
    public int ID { get; set; }
    public string Name { get; set; }
    public static int EmpCount { get; set; }


No comments:

Post a Comment