System.Xml.Schema.KeySequence.GetHashCode C# (CSharp) Method

GetHashCode() public method

public GetHashCode ( ) : int
return int
        public override int GetHashCode() {
            if (hashcode != -1) {
                return hashcode;
            }
            hashcode = 0;  // indicate it's changed. even the calculated hashcode below is 0
            for (int i = 0; i < this.ks.Length; i ++) {
                // extract its primitive value to calculate hashcode
                // decimal is handled differently to enable among different CLR types
                this.ks[i].SetDecimal();
                if (this.ks[i].IsDecimal) {
                    for (int j = 0 ; j < this.ks[i].Dim ; j ++) {
                        hashcode += this.ks[i].Dvalue[j].GetHashCode();
                    }
                }
                else {
                    Array arr = this.ks[i].Value as System.Array;
                    if (arr != null) {
                        XmlAtomicValue[] atomicValues = arr as XmlAtomicValue[];
                        if (atomicValues != null) {
                            for (int j = 0 ; j < atomicValues.Length ; j ++) {
                                hashcode += ((XmlAtomicValue)atomicValues.GetValue(j)).TypedValue.GetHashCode();
                            }
                        }
                        else {
                            for (int j = 0 ; j < ((Array) this.ks[i].Value).Length ; j ++) {
                                hashcode += ((Array) this.ks[i].Value).GetValue(j).GetHashCode();
                            }
                        }
                    }
                    else { //not a list
                        hashcode += this.ks[i].Value.GetHashCode();
                    }
                }
            }
            return hashcode;
        }