System.Xml.XmlName.GetHashCode C# (CSharp) Méthode

GetHashCode() public static méthode

public static GetHashCode ( string name ) : int
name string
Résultat int
        public static int GetHashCode(string name) {
            int hashCode = 0;
            if (name != null) {
                for (int i = name.Length - 1; i >= 0; i--) {
                    char ch = name[i];
                    if (ch == ':') break;
                    hashCode += (hashCode << 7) ^ ch;
                }
                hashCode -= hashCode >> 17;
                hashCode -= hashCode >> 11;
                hashCode -= hashCode >> 5;
            }
            return hashCode;
        }
    }

Usage Example

        public XmlName?GetName(string?prefix, string localName, string?ns, IXmlSchemaInfo?schemaInfo)
        {
            if (prefix == null)
            {
                prefix = string.Empty;
            }
            if (ns == null)
            {
                ns = string.Empty;
            }

            int hashCode = XmlName.GetHashCode(localName);

            for (XmlName e = _entries[hashCode & _mask]; e != null; e = e.next)
            {
                if (e.HashCode == hashCode &&
                    ((object)e.LocalName == (object)localName ||
                     e.LocalName.Equals(localName)) &&
                    ((object)e.Prefix == (object)prefix ||
                     e.Prefix.Equals(prefix)) &&
                    ((object)e.NamespaceURI == (object)ns ||
                     e.NamespaceURI.Equals(ns)) &&
                    e.Equals(schemaInfo))
                {
                    return(e);
                }
            }
            return(null);
        }
All Usage Examples Of System.Xml.XmlName::GetHashCode