I am having a proeprty class PropUser:
public class PropUser
{
public int UserId { get; set; }
public int ParentId { get; set; }
public PropProduct Product { get; set; }
}
here, 3rd property Product is object of PropProduct which is a another property class
public class PropProduct
{
public int ProductId { get; set; }
public string Name { get; set; }
public int Price { get; set; }
}
Now, in below code:
PropUser user = new PropUser();
user.Product.Name = "Reebok";
user.Product
is throwing Exception of "Object reference not set to an instance of an object."
I know user.Product
is null, so how to initialize that so that i can set user.Product.Name="Reebok"