How to declare a property in a class?

 Posted by SheoNarayan on 5/8/2008 | Category: C# Interview questions | Views: 5637

int m_PersonID = 0;

public int PersonID
get { return m_PersonID; }
set { m_PersonID = value; }

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Rajeev.Shukla on: 11/24/2011 | Points: 10
You can use Automatic properties provide by .Net framework 3.0 onwards as-

public int PersonID

If get is not required, make it as private. If set is not required make it as private.

Login to post response