How to initialize an Object?
Posted
by John
on Stack Overflow
See other posts from Stack Overflow
or by John
Published on 2010-04-05T16:52:43Z
Indexed on
2010/04/05
17:03 UTC
Read the original article
Hit count: 312
c#
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?
© Stack Overflow or respective owner