Click here to Skip to main content
15,902,112 members
Home / Discussions / C#
   

C#

 
GeneralRe: Class properties - how to change values from form Pin
Dan Mos10-Mar-10 12:10
Dan Mos10-Mar-10 12:10 
GeneralRe: Class properties - how to change values from form Pin
peropata10-Mar-10 19:54
peropata10-Mar-10 19:54 
QuestionC# dataset/adapter connection Pin
2010JohnFByers10-Mar-10 9:50
2010JohnFByers10-Mar-10 9:50 
AnswerRe: C# dataset/adapter connection Pin
Dan Mos10-Mar-10 10:09
Dan Mos10-Mar-10 10:09 
GeneralRe: C# dataset/adapter connection Pin
2010JohnFByers10-Mar-10 11:16
2010JohnFByers10-Mar-10 11:16 
GeneralRe: C# dataset/adapter connection Pin
Dan Mos10-Mar-10 11:30
Dan Mos10-Mar-10 11:30 
QuestionSet the SelectedItem of a populated DataGridViewComboBoxCell Pin
Member 226514810-Mar-10 7:44
Member 226514810-Mar-10 7:44 
QuestionCreating a list of complex object from two lists [modified] Pin
dan!sh 10-Mar-10 6:58
professional dan!sh 10-Mar-10 6:58 
Assume there are two classes: Zoo and Animals. Something like this:
public class Zoo{
public int Id;
public string Name;
public List< Animals > animals;
} 

public class Animals{
public int Id;
public string Name;
}


Now, I have two generic lists:

1. List of Zoo
2. List of Animals
3. Any kind of collection (I cannot decide which one to use) which will have Zoo.Id and Animal.Id. This collection would be used as a map between Zoo and Animals. Here each Zoo will have multiple animals and same animal can be a part of multiple zoos.

I need to get the list of Animals in a Zoo and then set that value to Zoo.animals list. I am thinking to use LINQ. Something like:

foreach(Zoo zoo in zooList){
zoo.animals = (from animal in animalList
               where collectionThree[animal.Id] = zoo.Id
               select animal).ToList();
}


But since collectionThree cannot be a Dictionary/HashTable, this wont work. Any ideas how to do this?
modified on Wednesday, March 10, 2010 10:56 PM

AnswerRe: Creating a list of complex object from two lists Pin
masoumeh201010-Mar-10 7:16
masoumeh201010-Mar-10 7:16 
AnswerRe: Creating a list of complex object from two lists Pin
Dan Mos10-Mar-10 7:29
Dan Mos10-Mar-10 7:29 
GeneralRe: Creating a list of complex object from two lists Pin
dan!sh 10-Mar-10 7:45
professional dan!sh 10-Mar-10 7:45 
AnswerRe: Creating a list of complex object from two lists Pin
Keith Barrow10-Mar-10 9:23
professionalKeith Barrow10-Mar-10 9:23 
GeneralRe: Creating a list of complex object from two lists Pin
Dan Mos10-Mar-10 10:26
Dan Mos10-Mar-10 10:26 
GeneralRe: Creating a list of complex object from two lists Pin
dan!sh 10-Mar-10 16:56
professional dan!sh 10-Mar-10 16:56 
QuestionHow installer can call non-System account action? Pin
dims1210-Mar-10 6:03
dims1210-Mar-10 6:03 
QuestionHow to use CutePDF Writer programmatically Pin
NarVish10-Mar-10 5:53
NarVish10-Mar-10 5:53 
AnswerRe: How to use CutePDF Writer programmatically Pin
JHizzle10-Mar-10 6:01
JHizzle10-Mar-10 6:01 
QuestionHow to top Visual Studio 2005 Designer from modifying my custom control! Pin
Matthew Klein10-Mar-10 5:28
Matthew Klein10-Mar-10 5:28 
AnswerRe: How to top Visual Studio 2005 Designer from modifying my custom control! Pin
The Man from U.N.C.L.E.10-Mar-10 5:52
The Man from U.N.C.L.E.10-Mar-10 5:52 
GeneralRe: How to top Visual Studio 2005 Designer from modifying my custom control! Pin
Matthew Klein10-Mar-10 6:12
Matthew Klein10-Mar-10 6:12 
GeneralRe: How to top Visual Studio 2005 Designer from modifying my custom control! Pin
Saksida Bojan10-Mar-10 7:31
Saksida Bojan10-Mar-10 7:31 
AnswerRe: How to top Visual Studio 2005 Designer from modifying my custom control! Pin
DaveyM6910-Mar-10 6:22
professionalDaveyM6910-Mar-10 6:22 
AnswerRe: How to top Visual Studio 2005 Designer from modifying my custom control! Pin
Matthew Klein10-Mar-10 6:59
Matthew Klein10-Mar-10 6:59 
QuestionChroma key Pin
AlexB4710-Mar-10 4:56
AlexB4710-Mar-10 4:56 
QuestionAnyway to check if a SqlConnection has a SqlTransaction open against it Pin
dlarkin7710-Mar-10 4:21
dlarkin7710-Mar-10 4:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.