Reputation: 119
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
Upvotes: 2
Views: 1197
Reputation: 81253
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
.
Upvotes: 6