Monday, February 1, 2010

How to add a ReadOnly property in C#.NET?

Properties can be made read-only by having only a get accessor in the implementation.
public class X
{
          public X(int id)
          {
               x_id = id;
          }
          public int ID
          {
              get
              {
                   return x_id;
              }
          }
}

0 Comments: