You need to create an object of UsersTB
and then assign a value to it's userID
.
prof.UserObj = new UserObj();
prof.UserObj.userID = 123;
When we create an instance of an object and we don't specify a value for it's properties, these properties take their default values. In this case by instantiating an obejct of type Profile
as below:
Profile prof = new Profile();
The values that you are stored in the backing fields of properties UserObj
and newPassword
are the corresponding default values for these type of objects, which in this case is in both cases null.
You could make all of the above in one step by using an object initializer:
var profile = new Profile
{
UserObj = new UserObj
{
userID = 123
}
};