Re: Duplicate Key Alternative for Generic Dictionary
- From: Samuel R. Neff <samuelneff@xxxxxxxxxx>
- Date: Tue, 18 Dec 2007 17:24:40 -0500
To me it sounds like you're trying to avoid creating a Department
object even though that is exactly what you need. This code would be
much easier to read and understand and manage and debug and on and on
and on..
var d1 = new Department();
var d2 = new Department();
var d3 = new Department();
var departments = new Dictionary<Guid, Department>();
departments.Add(d1.Guid, d1);
departments.Add(d2.Guid, d2);
departments.Add(d3.Guid, d3);
d1.Users.Add(new User());
d1.Users.Add(new User());
d1.Users.Add(new User());
d2.Users.Add(new User());
d2.Users.Add(new User());
d2.Users.Add(new User());
d3.Users.Add(new User());
d3.Users.Add(new User());
d3.Users.Add(new User());
3 departments in a dictionary, each with 3 users (employees). Not
fully working code (need class definitions), but hopefully this is
enough to explain.
HTH,
Sam
------------------------------------------------------------
We're hiring! B-Line Medical is seeking .NET
Developers for exciting positions in medical product
development in MD/DC. Work with a variety of technologies
in a relaxed team environment. See ads on Dice.com.
On Tue, 18 Dec 2007 16:23:16 -0500, "sloan" <sloan@xxxxxxxxx> wrote:
I guess pretend I have 3 departments, and 3 employees in each one.
That is the reason. I'm either going to have to wrap my own custom object
collection, or try and piggy back.
Guid dept1 = new Guid("00000000-0000-0000-0000-000000000001");
Guid dept2 = new Guid("00000000-0000-0000-0000-000000000002");
Guid dept3 = new Guid("00000000-0000-0000-0000-000000000003");
test.Add(dept1 , Guid.NewGuid());
test.Add(dept1 , Guid.NewGuid());
test.Add(dept1 , Guid.NewGuid());
test.Add(dept2 , Guid.NewGuid());
test.Add(dept2 , Guid.NewGuid());
test.Add(dept2 , Guid.NewGuid());
test.Add(dept3 , Guid.NewGuid());
test.Add(dept3 , Guid.NewGuid());
test.Add(dept3 , Guid.NewGuid());
.
- References:
- Duplicate Key Alternative for Generic Dictionary
- From: sloan
- Re: Duplicate Key Alternative for Generic Dictionary
- From: sloan
- Duplicate Key Alternative for Generic Dictionary
- Prev by Date: Re: Update multiple textboxes at once
- Next by Date: Re: Global Assembly Cache for exporting COM interface
- Previous by thread: Re: Duplicate Key Alternative for Generic Dictionary
- Next by thread: Re: Duplicate Key Alternative for Generic Dictionary
- Index(es):
Relevant Pages
|