Articles → CSHARP → Automatic Properties And Object Initializers In C#
Automatic Properties And Object Initializers In C#
Automatic Property
private int _age;
public int Age {
get {
return _age;
}
set {
_age = value;
}
}
public int Age {
get;
set;
}
Object Initializers
Person person = new Person();
person.Age = 32;
person.Name = " Test";
Response.Write(person.Age);
Response.Write(person.Name);
Person person = new Person {Name="Test",Age=32} ;
Response.Write ( person.Age ) ;
Response.Write ( person.Name ) ;