M
Mike
I have a class that has another class as a property, MainClass and SubClass.
I will create the SubClass and then pass it too the MainClass in the
constructor. The SubClass has alot of properties I only have three in the
example below but there are actually 20 so I dont want to set them all in
the constructor of the SubClass. When the MainClass is accessed I want to
allow read only access to the SubClass that is a property of the MainClass.
I know I could make sub class a sruct, but I dont think that is the best
solution, there must be an accepted way to do this or my design is flawed.
Any Suggestions?
Thanks,
Mike
class MainClass
{
MainClass(string otherProperty1, SubClass subClass)
{
this.SubClass = subClass;
}
SubClass SubClass;
string OtherProperty1;
}
class SubClass
{
string Property1;
string Property2;
string Property3;
}
I will create the SubClass and then pass it too the MainClass in the
constructor. The SubClass has alot of properties I only have three in the
example below but there are actually 20 so I dont want to set them all in
the constructor of the SubClass. When the MainClass is accessed I want to
allow read only access to the SubClass that is a property of the MainClass.
I know I could make sub class a sruct, but I dont think that is the best
solution, there must be an accepted way to do this or my design is flawed.
Any Suggestions?
Thanks,
Mike
class MainClass
{
MainClass(string otherProperty1, SubClass subClass)
{
this.SubClass = subClass;
}
SubClass SubClass;
string OtherProperty1;
}
class SubClass
{
string Property1;
string Property2;
string Property3;
}