I have object Item, and it has Data Object in it. In order to access Data's properties I use the following code:
Item.Data.PropertyName
Is any way in C# to access Data's properties in the following way:
Item.PropertyName
without copy properties to "Item" object?
Example of Item class:
class Item{
public DataObject Data;
public AnotherDataObject Data1;
public AnotherDataObject Data2;
}
class DataObject{
public int Property1;
public int Property2;
.....
}
class DataObject1{.....}
......
other DataObjects classess similar to DataObject Implementation
Yeah by having wrapper property in Item
class which will return PropertyName of Data
class -
public string PropertyName
{
get
{
return this.Data.PropertyName;
}
set
{
this.Data.PropertyName = value;
}
}
This way you can write Item.PropertyName
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.