当前位置:编程学习 > C#/ASP.NET >>

对于函数的重载——两个不理解的地方Equals和GetHashCode!!!

/*书上看到的这段,对于public override bool Equals(object other)
        {
            bool result = false;
            if (other != null)
            {
                if ((object)this == other)
                {
                    result = true;
                }
                else if (other is BattingAverage)
                {
                    BattingAverage otherAvg = (BattingAverage)other;
                    result = Average() == otherAvg.Average();
                }
            }
            return result;
        }

      
        public override int GetHashCode()
        {
            return ToString().GetHashCode();
        }
这两个方法的重载不是很理解!
这两个方法的重载在整个程序中有什么作用?这两个方法的重载是不是在所有自定义的
值类型中都是固定的代码段,如果事这样的话,我就不用理解其中的意义了?
*/  --------------------编程问答-------------------- 让你可以正确地比较两个引用类型的变量 --------------------编程问答-------------------- 对于BattingAverage类型如何比较
  
*****************************************************************************
欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 

http://feiyun0112.cnblogs.com/ --------------------编程问答-------------------- 还是不理解 能不能详细点。。。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,