How is a property designated as read-only?

Answer Posted / deep

In VB.NET:
Private mPropertyName as DataType
Public ReadOnly Property PropertyName() As DataType
Get Return mPropertyName
End Get
End Property
In C#
Private DataType mPropertyName;
public returntype PropertyName
{
get{
//property implementation goes here
return mPropertyName;
}
// Do not write the set implementation
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is machine key error in .NET how can we solve it?

2184


What is RPC? What is the use of it?

690


Explain the difference between .net 2000 and .net 2005(features)? Which one is better?

652


Can a try block have more than one catch block?

710


Different between .net & j2ee ?

684






Explain what is a delegate?

670


What data providers available in .net to connect to database?

606


What is a formatter in .net?

663


What is immutability?

662


What are the new thee features of com+ services, which are not there in com (mts)?

607


why you wouldn't want to write into it even if you could

666


Please explain what is a delegate?

813


What is cyclomatic complexity and why is it important?

1795


What is the difference between asp.net and asp?

667


Explain how viewstate is being formed and how it's stored on client in .net?

630