这里会详细解释:我有
public class Season
{
#region Public Variables
private int _id;
private string _seasonName;
private int _startMonth;
#endregion
#region Public Properties
public int Id
{
get { return _id; }
set { _id = value; }
}
public int StartMonth
{
get { return _startMonth; }
set { _startMonth = value; }
}
public string SeasonName
{
get { return _seasonName; }
set { _seasonName = value; }
}
#endregion
#region Public Constructor
public Season()
{
this._initialize();
}
public Season(string pSeasonName, int _pStartMonth,int pID)
{
this._initialize(pSeasonName, _pStartMonth, pID);
}
#endregion
}
接下来我有如下所示
IList<Season> seaosns = new List<Season>();
seaosns.Add(new Season("Summer", 4, 1));
seaosns.Add(new Season("Winter", 6, 2));
seaosns.Add(new Season("MidSummer", 10, 1));
在这里我需要检查 Ilist 项目中是否重复 Id。这可以通过使用 For 循环来完成,但需要知道是否有其他解决方案。
提前致谢。