删除我有一个类如下:定制的HashSet
public class User
{
public int ID { get; set; }
public int PPN { get; set; }
public User(int id, int ppn)
{
ID = id;
PPN = ppn;
}
}
其中我已经声明它的类型的一个HashSet。
HashSet<User> users = new HashSet<User>();
现在,我想删除下面的方法第5项:
public void Delete() {
users.Remove(5);
}
,但我得到了以下错误:
cannot convert from 'int' to 'User'
任何人都知道问题是什么,以及如何我能解决这个问题吗?
HashSet不保证顺序。你可能想要一个不同的集合类型 – Jonesopolis 2014-11-24 13:05:11