How to initialize an Object?
- by John
I have a class like this,
public class person
{
name Name {set; get;}
string Address {set; get;}
}
public class name
{
string First {set; get;}
string Last {set; get;}
}
Now when I create the object an try to set the first or last name I get an error. "Object reference not set to an instance of an object."
person Person = new person();
Person.Name.First = "John";
Person.Name.Last ="Smith";
What am I doing wrong?