C# Get/Set Syntax Usage

Posted by RoR on Stack Overflow See other posts from Stack Overflow or by RoR
Published on 2011-01-11T20:46:24Z Indexed on 2011/01/11 20:53 UTC
Read the original article Hit count: 127

Filed under:

These are declarations for a Person class.

protected int ID { get; set; }
protected string Title { get; set; }
protected string Description { get; set; }
protected TimeSpan jobLength { get; set; }

How do I go about using the get/set? In main, I instantiate a

Person Tom = new Person();

How does Tom.set/get??

I am use to doing C++ style where you just write out the int getAge() and void setAge() functions. But in C# there are shortcuts handling get and set?

© Stack Overflow or respective owner

Related posts about c#