Monday, November 28, 2011

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;
}
}
}

No comments:

Post a Comment