Advertisement
vencinachev

HashMain

Sep 12th, 2019
275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1.  class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             Student st1 = new Student("Petkan", 20);
  6.             Student st2 = new Student("Dragan", 30);
  7.             Student st3 = new Student("Petkan", 20);
  8.             Student st4 = st1;
  9.  
  10.             Console.WriteLine(st1.GetHashCode());
  11.             Console.WriteLine(st2.GetHashCode());
  12.             Console.WriteLine(st3.GetHashCode());
  13.             Console.WriteLine(st4.GetHashCode());
  14.  
  15.             Console.WriteLine(st1.Equals(st2));
  16.             Console.WriteLine(st1.Equals(st3));
  17.             Console.WriteLine(st1.Equals(st4));
  18.  
  19.             HashSetMy<int> hs = new HashSetMy<int>();
  20.             hs.AddItem(10);
  21.             hs.AddItem(20);
  22.             hs.AddItem(30);
  23.             hs.AddItem(40);
  24.             hs.AddItem(50);
  25.             hs.AddItem(50);
  26.             hs.AddItem(60);
  27.             hs.Remove(30);
  28.             Console.WriteLine(string.Join(" ", hs));
  29.  
  30.  
  31.         }
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement