Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- List<Person> people = new List<Person>();
- people.Add(new Person() { Name = "Том", Id = "Id_1" });
- people.Add(new Person() { Name = "Том", Id = "Id_2" });
- people.Add(new Person() { Name = "Ипполит", Id = "Id_3" });
- people.Add(new Person() { Name = "Евкакий", Id = "Id_4" });
- people.Add(new Person() { Name = "Евкакий", Id = "Id_5" });
- foreach (var eee in people)
- {
- var key = eee.Name;
- if (!dictionaryElement.ContainsKey(key))
- {
- dictionaryElement[key] = new List<Id>();
- dictionaryElement[key].Add(eee.Id);
- }
- }
- if (!dictionaryElement.ContainsKey(key))
- dictionaryElement[key] = new List<Id>();
- dictionaryElement[key].Add(eee.Id);
Add Comment
Please, Sign In to add comment