Advertisement
Guest User

Untitled

a guest
Apr 6th, 2020
242
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.68 KB | None | 0 0
  1.         private class Group
  2.         {
  3.             public string Name { get; set; }
  4.         }
  5.  
  6.         private List<Group> _groups;
  7.  
  8.         private string Check(string newName, Group group = null)
  9.         {
  10.             while (_groups.Where(gr => gr != group).Select(gr => gr.Name).Contains(newName))
  11.             {
  12.                 newName += "1";
  13.             }
  14.  
  15.             return newName;
  16.         }
  17.  
  18.         public void DoAdd()
  19.         {
  20.             var group = new Group();
  21.  
  22.             group.Name = Check(group.Name);
  23.         }
  24.  
  25.         public void DoRename()
  26.         {
  27.             var group = new Group();
  28.  
  29.             group.Name = Check(group.Name, group);
  30.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement