Is it a good design to have a Class with List of class same class objects
Is it a good design to have a Class with List of class same class objects
(OP)
Hi
We have a requirement to create a class like this
Class Bundle
{
int BundleId;
string BundleName;
double NRC;
double ARC;
List<Bundle> BundleList;
int NestedBundleId; //This is the parent BundleId
}
The reason we trying this is we need an xml output like this
<Bundle>
<BundleId>
<BundleName>
<NRC>
<ARC>
<Bundle> //This is based on the nested bundleId
<BundleId>
<BundleName>
</Bundle>
<NRC>
<ARC>
</Bundle>
Can you guys have your opinion on what is the best way to get this structure done as I thought about the circular reference initially, but in this instance there is no circular reference as it just creates new list of bundles
what we doing in c# is
Bundle bundle = new Bundle();
List<Bundle> nestedBundleList= new List<Bundle>
bundle.BundleList = nestedBundleList;
Thanks
We have a requirement to create a class like this
Class Bundle
{
int BundleId;
string BundleName;
double NRC;
double ARC;
List<Bundle> BundleList;
int NestedBundleId; //This is the parent BundleId
}
The reason we trying this is we need an xml output like this
<Bundle>
<BundleId>
<BundleName>
<NRC>
<ARC>
<Bundle> //This is based on the nested bundleId
<BundleId>
<BundleName>
</Bundle>
<NRC>
<ARC>
</Bundle>
Can you guys have your opinion on what is the best way to get this structure done as I thought about the circular reference initially, but in this instance there is no circular reference as it just creates new list of bundles
what we doing in c# is
Bundle bundle = new Bundle();
List<Bundle> nestedBundleList= new List<Bundle>
bundle.BundleList = nestedBundleList;
Thanks
RE: Is it a good design to have a Class with List of class same class objects
I would probably just use the XML node writing functions already part .Net.
Yours:
<Bundle>
<BundleId>
<BundleName>
<NRC>
<ARC>
<Bundle> //This is based on the nested bundleId
<BundleId>
<BundleName>
</Bundle>
<NRC>
<ARC>
</Bundle>
What I suspect you want:
<Bundle>
<BundleId>
<BundleName>
<NRC>
<ARC>
<Bundle> //This is based on the nested bundleId
<BundleId>
<BundleName>
<NRC>
<ARC>
</Bundle>
</Bundle>
Walt
IT Consulting for Robert Half
http://roberthalftechnology.com