A
Author
I wrote a simple Person class with Visual C# 2008 Express Edition, in
which I define two properties: FirstName and LastName.
If I use the new c# automatic property feature, it *compiles with no
problem*, but I don't get the value through the property.
If I use the regular old style property definition, then it works
perfect.
// does not work
public string FirstName
{
get;
set;
}
// does not work
public string LastName
{
get;
set;
}
// The following works.
public string FirstName
{
get
{
return this.firstName;
}
set
{
this.firstName = value;
}
}
public string LastName
{
get
{
return this.lastName;
}
set
{
this.lastName = value;
}
}
How come? Am I not using C# 3.0?
which I define two properties: FirstName and LastName.
If I use the new c# automatic property feature, it *compiles with no
problem*, but I don't get the value through the property.
If I use the regular old style property definition, then it works
perfect.
// does not work
public string FirstName
{
get;
set;
}
// does not work
public string LastName
{
get;
set;
}
// The following works.
public string FirstName
{
get
{
return this.firstName;
}
set
{
this.firstName = value;
}
}
public string LastName
{
get
{
return this.lastName;
}
set
{
this.lastName = value;
}
}
How come? Am I not using C# 3.0?