Read-only Properties

You can also create read-only properties if you omit the set accessor method. For example, to make the Name property a read-only property, you use this code:

class Customer
{
  private string name;

  public string Name
					  {
					   get
					   {
					     return name;
					   }
					  }
}
				

Get Microsoft® Visual C#® .NET 2003 Kick Start now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.