1. Using Constructor
class Person
{
public Person()
{
Name = "Default Name";
}
public string Name { get; set; }
}
2. Normalprivate string name = "Default Name";
public string Name
{
get
{
return name;
}
set
{
name = value;
}
}
No comments:
Post a Comment