Possible Duplicate:
C#: Public Fields versus Automatic Properties
class Person
{
public Person()
{
Name = "Default Name";
}
public string Name { get; set; }
}
vs.
class Person
{
public Person()
{
Name = "Default Name";
}
public string Name;
}
What is the advantage of the first?
If using like,
public string Name { get; private set; }
then I understand it.
And yes- I understand why to use properties in object oriented programming.
(and I know also in run-time there will be an private instance of name - but I cannot see
the big difference - if you just using it like public string [variable] { get; set; }
)