Advertisement
Guest User

Untitled

a guest
Mar 27th, 2015
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1.         //3.
  2.         public int CompareTo(Student other)
  3.         {
  4.             if (this.FirstName.CompareTo(other.FirstName) != 0)
  5.             {
  6.                 return this.FirstName.CompareTo(other.FirstName);
  7.             }
  8.             if (this.MiddleName.CompareTo(other.MiddleName) != 0)
  9.             {
  10.                 return this.MiddleName.CompareTo(other.MiddleName);
  11.             }
  12.             if (this.LastName.CompareTo(other.LastName) != 0)
  13.             {
  14.                 return this.LastName.CompareTo(other.LastName);
  15.             }
  16.             if (this.Ssn.CompareTo(other.Ssn) != 0)
  17.             {
  18.                 return this.Ssn.CompareTo(other.Ssn);
  19.             }
  20.             return 0;
  21.         }
  22.  
  23.  
  24.  
  25.         public int CompareTo(Object obj)
  26.         {
  27.             if (obj != null && !(obj is Student))
  28.             {
  29.                 throw new ArgumentException("Object must be of type Student.");
  30.             }
  31.  
  32.             return CompareTo(obj as Student);
  33.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement