C# inner object’s touch notation.
The notation will not create or change the internal object.
That's it
Required that the inner object was created before of use.
The full example:
Inner = {CompanyName = "Any name"}
That's it
var obj = new Obj
{
Inner = {CompanyName = "Any name"}
};
Required that the inner object was created before of use.
The full example:
class Program
{
static void Main()
{
var obj = new Obj
{
};
}
}
class Obj
{
private InnerObj _inner = new InnerObj();
public InnerObj Inner
{
get
{
return _inner;
}
set
{
_inner = value;
}
}
}
class InnerObj
{
private string _companyName;
public String CompanyName
{
get
{
return _companyName;
}
set
{
_companyName = value;
}
}
}
Comments
Post a Comment