当前位置: 首页>>代码示例>>C#>>正文


C# Object.GetHashCode方法代码示例

本文整理汇总了C#中Object.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Object.GetHashCode方法的具体用法?C# Object.GetHashCode怎么用?C# Object.GetHashCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Object的用法示例。


在下文中一共展示了Object.GetHashCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Go

   public static void Go() {
      Console.WriteLine();			// Call a static method

      Object o = new Object();
      o.GetHashCode();				// Call a virtual instance method
      o.GetType();					// Call a nonvirtual instance method
   }
开发者ID:Helen1987,项目名称:edu,代码行数:7,代码来源:Ch06-1-TypeMembers.cs

示例2: ArgumentNullException

        int IEqualityComparer.GetHashCode ( Object obj ) {
            int hashCode;
            XPathNavigator nav;
            XPathDocumentNavigator xpdocNav;

            if (obj == null) {
                throw new ArgumentNullException("obj");
            }
            else if ( null != (xpdocNav = obj as XPathDocumentNavigator) ) {
                hashCode = xpdocNav.GetPositionHashCode();
            }
            else if( null != (nav = obj as XPathNavigator) ) {
                Object underlyingObject = nav.UnderlyingObject;
                if (underlyingObject != null) {
                    hashCode = underlyingObject.GetHashCode();
                }
                else {
                    hashCode = (int)nav.NodeType;
                    hashCode ^= nav.LocalName.GetHashCode();
                    hashCode ^= nav.Prefix.GetHashCode();
                    hashCode ^= nav.NamespaceURI.GetHashCode();
                }
            } 
            else {
                hashCode = obj.GetHashCode();
            }
            return hashCode;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:28,代码来源:XPathNavigatorKeyComparer.cs

示例3: GetHashCode

        public virtual int GetHashCode(Object o) {
            String obj = o as string;
            if (obj == null) {
                return o.GetHashCode();
            }

            return BackCompatibleStringComparer.GetHashCode(obj);
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:8,代码来源:CompatibleIComparer.cs

示例4: GetHashCode

        public int GetHashCode(Object obj) {
            if( obj == null) {
                throw new ArgumentNullException("obj");
            }

            if (_hcp != null)
                return _hcp.GetHashCode(obj);
            return obj.GetHashCode();
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:9,代码来源:compatiblecomparer.cs

示例5: GetHashCode

        public int GetHashCode(Object obj) {
            if( obj == null) {
                throw new ArgumentNullException(nameof(obj));
            }
            Contract.EndContractBlock();

            if (_hcp != null)
                return _hcp.GetHashCode(obj);
            return obj.GetHashCode();
        }
开发者ID:JonHanna,项目名称:coreclr,代码行数:10,代码来源:CompatibleComparer.cs

示例6: GetHash

 // Internal method to get the hash code for an Object.  This will call
 // GetHashCode() on each object if you haven't provided an IHashCodeProvider
 // instance.  Otherwise, it calls hcp.GetHashCode(obj).
 protected virtual int GetHash(Object key)
 {
     if (_keycomparer != null)
         return _keycomparer.GetHashCode(key);
     return key.GetHashCode();
 }
开发者ID:ChuangYang,项目名称:corefx,代码行数:9,代码来源:Hashtable.cs

示例7: HashableSerializedProperty

		/// <summary>
		/// Initializes a new instance of the
		/// <see cref="PropertyBackingFieldDrawer+HashableSerializedProperty"/> struct.
		/// </summary>
		/// <param name="path">Path.</param>
		/// <param name="target">Target.</param>
		public HashableSerializedProperty(string path, Object target) : this()
		{
			m_PropertyPath = path;
			m_TargetObject = target;
			// store the hash upon construction, in case the object is killed later
			m_Hash = ObjectX.GenerateHashCode(m_PropertyPath.GetHashCode(), m_TargetObject.GetHashCode());
		}
开发者ID:claudia-gp,项目名称:oblivious-oscar,代码行数:13,代码来源:PropertyBackingFieldDrawer.cs

示例8: TestHelpersGetObjectValue

	// Test "RuntimeHelpers.GetObjectValue".
	public void TestHelpersGetObjectValue()
			{
				// Null's value is itself.
				AssertNull("GetObjectValue (1)",
						   RuntimeHelpers.GetObjectValue(null));

				// Object references map to themselves.
				Object obj = new Object();
				AssertSame("GetObjectValue (2)", obj,
						   RuntimeHelpers.GetObjectValue(obj));

				// Immutable primitive types map to themselves.
				obj = (Object)3;
				AssertSame("GetObjectValue (3)", obj,
						   RuntimeHelpers.GetObjectValue(obj));
				obj = (Object)(AttributeTargets.Assembly);
				AssertSame("GetObjectValue (4)", obj,
						   RuntimeHelpers.GetObjectValue(obj));

				// Other value types are cloned.
				GetObjectValueTest t = new GetObjectValueTest(3);
				obj = (Object)t;
				Object clone = RuntimeHelpers.GetObjectValue(obj);
				AssertNotSame("GetObjectValue (5)", obj, clone);
				AssertEquals("GetObjectValue (6)",
							 ((GetObjectValueTest)obj).value,
							 ((GetObjectValueTest)clone).value);
				obj.GetHashCode();	// side-effect value.
				AssertEquals("GetObjectValue (7)", 4,
							 ((GetObjectValueTest)obj).value);
				AssertEquals("GetObjectValue (8)", 3,
							 ((GetObjectValueTest)clone).value);
			}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:34,代码来源:TestCompilerServices.cs

示例9:

 int IEqualityComparer.GetHashCode(Object obj)
 {
     return obj.GetHashCode();
 }
开发者ID:chcosta,项目名称:corefx,代码行数:4,代码来源:WeakHashtable.cs

示例10: GetHashCode

 public Int32 GetHashCode(Object obj1)
 {
     return obj1.GetHashCode();
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:4,代码来源:co8612ctor_isii.cs

示例11: Equals

            /**
             * <inheritdoc />
             */
            public override bool Equals(Object obj)
            {
                CIE1960 ucsObj = obj as CIE1960;

                if (ucsObj == this) {
                    return true;
                }
                if (ucsObj == null || GetHashCode () != obj.GetHashCode ()) {
                    return false;
                }

                return (U == ucsObj.U && V == ucsObj.V && W == ucsObj.W);
            }
开发者ID:AlanParr,项目名称:ColorSharp,代码行数:16,代码来源:CIE1960.cs

示例12: GetHashCode

		// Get the hash code for an object.
		public int GetHashCode(Object obj)
				{
					if(obj != null)
					{
						return obj.GetHashCode();
					}
					else
					{
						return 0;
					}
				}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:12,代码来源:KeyComparer.cs

示例13: GetHash

 protected virtual int GetHash(Object key)
 {
     //获取哈希码
     return key.GetHashCode();
 }
开发者ID:yfann,项目名称:CSharp_Algorithm,代码行数:5,代码来源:MyHashTable.cs

示例14: hash

 private int hash(Object obj)
 {
     return obj.GetHashCode()/*System.identityHashCode(obj)*/ & 0x7FFFFFFF;
 }
开发者ID:jason-persson,项目名称:LibPhoneNumberPortable,代码行数:4,代码来源:ObjectOutputStream.cs

示例15: test_0_intrins_object_gethashcode

	public static int test_0_intrins_object_gethashcode () {
		object o = new Object ();

		return (o.GetHashCode () == o.GetHashCode ()) ? 0 : 1;
	}
开发者ID:kumpera,项目名称:mono,代码行数:5,代码来源:objects.cs


注:本文中的Object.GetHashCode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。