예제 #1
0
파일: Student.cs 프로젝트: ieronimb/Week6
 //Override GetHashCode()
 public override int GetHashCode() //https://docs.microsoft.com/en-us/dotnet/api/system.object.gethashcode?view=netframework-4.8
 {
     return(FirstName.GetHashCode()
            ^ MiddleName.GetHashCode()
            ^ LastName.GetHashCode()
            ^ SSN.GetHashCode());  //https://www.tutorialspoint.com/csharp/csharp_operators.htm Binary XOR Operator copies the bit if it is set in one operand but not both.	(A ^ B) = 49, which is 0011 0001
 }
예제 #2
0
    public override int GetHashCode()
    {
        // using prime numbers to multiply

        int hash           = 29;
        int hashMultiplier = 11;

        // overflow is ok for hashing

        unchecked
        {
            // use multyplying and the fields' own hashcode to generate a unique code for the student

            hash = hash * hashMultiplier + string.Format("{0} {1} {2}", FirstName, MiddleName, LastName).GetHashCode();
            hash = hash * hashMultiplier + Adress.GetHashCode();
            hash = hash * hashMultiplier + Course.GetHashCode();
            hash = hash * hashMultiplier + Email.GetHashCode();
            hash = hash * hashMultiplier + Faculty.GetHashCode();
            hash = hash * hashMultiplier + Phone.GetHashCode();
            hash = hash * hashMultiplier + SSN.GetHashCode();
            hash = hash * hashMultiplier + University.GetHashCode();
            hash = hash * hashMultiplier + Specialty.GetHashCode();
        }

        return(hash);
    }
예제 #3
0
        public override int GetHashCode()
        {
            int    hash = 13;
            Random rand = new Random();

            hash = (hash * 7) + SSN.GetHashCode();
            hash = (hash * rand.Next(1, 1000));
            hash = (hash * counter);
            return(hash);
        }
예제 #4
0
 public override int GetHashCode()
 {
     return(FirstName.GetHashCode() ^
            MiddleName.GetHashCode() ^
            LastName.GetHashCode() ^
            SSN.GetHashCode() ^
            PermanentAddress.GetHashCode() ^
            MobilePhoneNr.GetHashCode() ^
            Email.GetHashCode() ^
            Course.GetHashCode() ^
            Speciality.GetHashCode() ^
            University.GetHashCode() ^
            Faculty.GetHashCode());
 }
예제 #5
0
        public override int GetHashCode()
        {
            int hash           = 29;
            int hashMultiplier = 11;

            unchecked
            {
                hash = hash * hashMultiplier + string.Format("{0} {1} {2}", FirstName, MiddleName, LastName).GetHashCode();
                hash = hash * hashMultiplier + Adress.GetHashCode();
                hash = hash * hashMultiplier + Course.GetHashCode();
                hash = hash * hashMultiplier + Email.GetHashCode();
                hash = hash * hashMultiplier + Faculty.GetHashCode();
                hash = hash * hashMultiplier + Phone.GetHashCode();
                hash = hash * hashMultiplier + SSN.GetHashCode();
                hash = hash * hashMultiplier + University.GetHashCode();
                hash = hash * hashMultiplier + Specialty.GetHashCode();
            }

            return(hash);
        }
예제 #6
0
        public override int GetHashCode()
        {
            var hashCode = -684685926;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(LastName);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(FirstName);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(MidlleName);

            hashCode = hashCode * -1521134295 + SSN.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Adress);

            hashCode = hashCode * -1521134295 + MobilePhone.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Email);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Course);

            hashCode = hashCode * -1521134295 + Specialitate.GetHashCode();
            hashCode = hashCode * -1521134295 + Universitate.GetHashCode();
            hashCode = hashCode * -1521134295 + Facultate.GetHashCode();
            return(hashCode);
        }
예제 #7
0
 public override int GetHashCode()
 {
     return(LastName.GetHashCode() ^ SSN.GetHashCode() ^ Mobile.GetHashCode());
 }
예제 #8
0
        public override int GetHashCode()
        {
            int hash = SSN.GetHashCode();

            return(31 * hash);
        }
예제 #9
0
파일: Student.cs 프로젝트: vlad4109/week02
 public override int GetHashCode()
 {
     return(FirstName.GetHashCode() ^ SSN.GetHashCode());
 }
예제 #10
0
 public override int GetHashCode()
 {
     return(SSN.GetHashCode() ^ PermanentAddress.GetHashCode());
 }
예제 #11
0
 public override int GetHashCode()
 {
     return(SSN.GetHashCode());
 }
예제 #12
0
파일: Student.cs 프로젝트: RobinJS/dotNET
 public override int GetHashCode()
 {
     return(FirstName.GetHashCode() ^ MiddleName.GetHashCode() ^ LastName.GetHashCode() ^ SSN.GetHashCode() ^ Phone.GetHashCode());
 }
예제 #13
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode() ^ SSN.GetHashCode() & Email.GetHashCode());
 }