How is a property designated as read-only?

Q

How is a property designated as read-only?

✍: Guest

A

In VB.NET:
Public ReadOnly Property PropertyName As ReturnType
Get ‘Your Property Implementation goes in here
End Get
End Property

in C#
public returntype PropertyName
{
get{
//property implementation goes here
}
// Do not write the set implementation
}

2014-02-07, 1608👍, 0💬