Writing Read-only properties in C# as well as VB.Net.

Posted by Rajesh_Kumar under Visual Studio category on | Points: 40 | Views : 513
In C#,it's very simple to write Read-Only property.

There is only Get keyword inside property,no Set keyword.

private int _project_id;

public int Project_ID
get { return _project_id; }
But in case of VB.Net,we have to use Readonly keyword in property declaration like below:

Private _project_id As Integer

Public ReadOnly Property Project_Id() As Integer
Return _project_id
End Get
End Property

Comments or Responses

Login to post response