private string name;
public string Name
{
get { return name; }
set { name = value; }
}
In the above, why doesn't C# just allow one to create a single directive to
make a property?
why not something like
public string Name
{
get { return name; }
set { name = value; }
}
Why the need to declare the same thing basically twice? If, say there was no
block associated with the variable then its assumed to be a field instead of
a property.
i.e.
public string Name; works and is a "Field".
while
public string Name
{
get { return name; }
set { name = value; }
}
is a property.
Thanks,
Jon
public string Name
{
get { return name; }
set { name = value; }
}
In the above, why doesn't C# just allow one to create a single directive to
make a property?
why not something like
public string Name
{
get { return name; }
set { name = value; }
}
Why the need to declare the same thing basically twice? If, say there was no
block associated with the variable then its assumed to be a field instead of
a property.
i.e.
public string Name; works and is a "Field".
while
public string Name
{
get { return name; }
set { name = value; }
}
is a property.
Thanks,
Jon
Comment