Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I think this forum rocks it has saved my bacon many many times..."

Geography

Where in the world do Tek-Tips members come from?

Is it a good design to have a Class with List of class same class objects

john121 (Programmer)
3 Aug 12 4:56
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
NESWalt (Programmer)
3 Aug 12 9:51
Let's look at your XML... you have an issue already with it.... you have two NRC/ARC in the root node... Do you mean to have that in the nested node and not the root node?

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

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close