K
kevin_g_frey
Hello All,
I have an MC++ class named "Person" which encapsulates access to a
database entity and it contains a number of field properties eg. Code,
Name, Address, Suburb etc.
Each of the field properties is of type "Field", so we have eg.
__property Field* get_Code( );
__property Field* get_Name( );
etc
The Field class itself has a number of properties such as:
__property String* get_Value( );
__property bool get_IsMandatory( );
etc
My question is this:
To store a value into the "Code" field of a "Person" object I have to
write (from eg. C#):
person.Code.Value = "MyValue";
Under COM I believe it was possible to designate one property in an
object as being the "default property" and therefore the need to
reference that property explicitly disappeared. So the above example
becomes:
person.Code = "MyValue"; // NOTE: "Value" is the default property
Can someone tell me if this possible in .NET? Or perhaps more
importantly is whether this is even an accepted idiom in .NET?
I know there is the "DefaultProperty" attribute that can assigned to a
class, but that is only useful for Indexable properties (eg. an Items
container).
Thanks
Kevin
I have an MC++ class named "Person" which encapsulates access to a
database entity and it contains a number of field properties eg. Code,
Name, Address, Suburb etc.
Each of the field properties is of type "Field", so we have eg.
__property Field* get_Code( );
__property Field* get_Name( );
etc
The Field class itself has a number of properties such as:
__property String* get_Value( );
__property bool get_IsMandatory( );
etc
My question is this:
To store a value into the "Code" field of a "Person" object I have to
write (from eg. C#):
person.Code.Value = "MyValue";
Under COM I believe it was possible to designate one property in an
object as being the "default property" and therefore the need to
reference that property explicitly disappeared. So the above example
becomes:
person.Code = "MyValue"; // NOTE: "Value" is the default property
Can someone tell me if this possible in .NET? Or perhaps more
importantly is whether this is even an accepted idiom in .NET?
I know there is the "DefaultProperty" attribute that can assigned to a
class, but that is only useful for Indexable properties (eg. an Items
container).
Thanks
Kevin