Guest User

Untitled

a guest
Nov 19th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. List<Person> people = new List<Person>();
  2. people.Add(new Person() { Name = "Том", Id = "Id_1" });
  3. people.Add(new Person() { Name = "Том", Id = "Id_2" });
  4. people.Add(new Person() { Name = "Ипполит", Id = "Id_3" });
  5. people.Add(new Person() { Name = "Евкакий", Id = "Id_4" });
  6. people.Add(new Person() { Name = "Евкакий", Id = "Id_5" });
  7.  
  8. foreach (var eee in people)
  9. {
  10. var key = eee.Name;
  11. if (!dictionaryElement.ContainsKey(key))
  12. {
  13. dictionaryElement[key] = new List<Id>();
  14. dictionaryElement[key].Add(eee.Id);
  15. }
  16. }
  17.  
  18. if (!dictionaryElement.ContainsKey(key))
  19. dictionaryElement[key] = new List<Id>();
  20. dictionaryElement[key].Add(eee.Id);
Add Comment
Please, Sign In to add comment