This is my C# class and its compatible with all .Net framework versions.
public class Person
{
// Fields
private string _name;
private int _age;
private string _city;
private string _company;
// Properties
public string Name
{
get { return _name; }
set { _name = value; }
}
public int Age
{
get { return _age; }
set { _age = value; }
}
public string City
{
get { return _city; }
set { _city = value; }
}
public string Company
{
get { return _company; }
set { _company = value; }
}
}
From the last bit of class code every thing is old so what is new.
Here is new technique in C# 3.0 to define properties in the terse and brief syntax like this,
Person objPerson new Person {Name=”Saqib Ullah”, City=”Karachi”, Company=”InboxBiz”, Age=26}
I hope this post increase your C# 3.0 little bit.