コード例 #1
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);
    }
コード例 #2
0
 public override int GetHashCode()
 {
     unchecked {
         const int randomPrime = 397;
         int       hashCode    = Id.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ (Name != null ? Name.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Adress != null ? Adress.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Country != null ? Country.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (Phone != null ? Phone.GetHashCode() : 0);
         hashCode = (hashCode * randomPrime) ^ (WebPages != null ? WebPages.GetHashCode() : 0);
         return(hashCode);
     }
 }
コード例 #3
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);
        }
コード例 #4
0
ファイル: User.cs プロジェクト: ishakdolek/GrpcDemo
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Adress.Length != 0)
            {
                hash ^= Adress.GetHashCode();
            }
            if (Age != 0)
            {
                hash ^= Age.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
コード例 #5
0
 public override int GetHashCode()
 {
     return(College.GetHashCode() ^ Department.GetHashCode() ^ Track.GetHashCode() ^ Name.GetHashCode() ^ Lab.GetHashCode() ^ Adress.GetHashCode() ^ Email.GetHashCode());
 }
コード例 #6
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode() + Adress.GetHashCode() + Semester.GetHashCode() + GenderType.GetHashCode());
 }
コード例 #7
0
 public override int GetHashCode()
 {
     return(Name.GetHashCode() ^ Adress.GetHashCode() ^ Year.GetHashCode());
 }