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


C# Object.equals方法代码示例

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


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

示例1: Compare

 //public double GetDefault() {
 //   return 1.0;
 //}
 /// This is used to compare the expected and current versions of
 /// the class. Once compared the comparison result is cached
 /// within the revision class so that it can be used repeatedly.
 /// </summary>
 /// <param name="expected">
 /// this is the expected version of the class
 /// </param>
 /// <param name="current">
 /// this is the current version of the class
 /// </param>
 /// <returns>
 /// this returns true if the versions are the same
 /// </returns>
 public bool Compare(Object expected, Object current) {
    if(current != null) {
       equal = current.equals(expected);
    } else if(expected != null) {
       equal = expected.equals(1.0);
    }
    return equal;
 }
开发者ID:ngallagher,项目名称:simplexml,代码行数:24,代码来源:Revision.cs

示例2: isEqualKey

 /**
  * Is the key equal to the combined key.
  *
  * @param entry  the entry to compare to
  * @param key1  the first key
  * @param key2  the second key
  * @param key3  the third key
  * @param key4  the fourth key
  * @return true if the key matches
  */
 protected bool isEqualKey(AbstractHashedMap.HashEntry entry, Object key1, Object key2, Object key3, Object key4)
 {
     MultiKey multi = (MultiKey)entry.getKey();
     return
         multi.size() == 4 &&
         (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
         (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
         (key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) &&
         (key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3)));
 }
开发者ID:gadfly,项目名称:nofs,代码行数:20,代码来源:org.apache.commons.collections.map.MultiKeyMap.cs

示例3: removeAll

 /**
  * Removes all mappings where the first four keys are those specified.
  * <p>
  * This method removes all the mappings where the <code>MultiKey</code>
  * has four or more keys, and the first four match those specified.
  *
  * @param key1  the first key
  * @param key2  the second key
  * @param key3  the third key
  * @param key4  the fourth key
  * @return true if any elements were removed
  */
 public bool removeAll(Object key1, Object key2, Object key3, Object key4)
 {
     bool modified = false;
     MapIterator it = mapIterator();
     while (it.hasNext())
     {
         MultiKey multi = (MultiKey)it.next();
         if (multi.size() >= 4 &&
             (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
             (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
             (key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) &&
             (key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3))))
         {
             it.remove();
             modified = true;
         }
     }
     return modified;
 }
开发者ID:gadfly,项目名称:nofs,代码行数:31,代码来源:org.apache.commons.collections.map.MultiKeyMap.cs

示例4: cardinality

 /**
  * Returns the number of occurrences of <i>obj</i> in <i>coll</i>.
  *
  * @param obj  the object to find the cardinality of
  * @param coll  the collection to search
  * @return the the number of occurrences of obj in coll
  */
 public static int cardinality(Object obj, java.util.Collection<Object> coll)
 {
     if (coll is java.util.Set<Object>)
     {
         return (coll.contains(obj) ? 1 : 0);
     }
     if (coll is Bag)
     {
         return ((Bag)coll).getCount(obj);
     }
     int count = 0;
     if (obj == null)
     {
         for (java.util.Iterator<Object> it = coll.iterator(); it.hasNext(); )
         {
             if (it.next() == null)
             {
                 count++;
             }
         }
     }
     else
     {
         for (java.util.Iterator<Object> it = coll.iterator(); it.hasNext(); )
         {
             if (obj.equals(it.next()))
             {
                 count++;
             }
         }
     }
     return count;
 }
开发者ID:gadfly,项目名称:nofs,代码行数:40,代码来源:org.apache.commons.collections.CollectionUtils.cs


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