list contains 类

Subscription sub = new Subscription();
sub.Appname = subName;
if (this.Subscriptions.Contains(sub,new SubcriptionComparer<Subscription>()))
  return true;
else
  return false;
class SubcriptionComparer<T> : IEqualityComparer<T>
where T : Subscription
{
  public int GetHashCode(T obj)
  {
    return obj.GetHashCode();
  }
  public bool Equals(T t1, T t2)
  {
    return t1.Appname == t2.Appname;
  }
}

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注