Sunday, July 1, 2012

Add ReadOnly property in C#.NET?


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


Properties can be made read-only by having only a get accessor in the implementation. For example


public class X
{
          public X(int id)
          {
               x_id = id;
          }
          public int ID
          {
              get
              {
                   return x_id;
              }
          }
}

1 comment:

  1. Are you looking to earn money from your traffic using popup ads?
    If so, did you try using Propeller Ads?

    ReplyDelete