public class DoctorsData
{
string _doctorName;
public string DoctorName { get { return _doctorName; } }
string _doctorAge;
public string DoctorAge { get { return _doctorAge; } }
string _doctorCity;
public string DoctorCity
{
get { return _doctorCity; }
set { _doctorCity = value; }
}
string _doctorDesc;
public string desc
{
get
{
return _doctorDesc;
}
set
{
_doctorDesc = value;
}
}
public DoctorsData(string doctorname, string doctorage, string doctorcity, string doctordesc)
{
_doctorName = doctorname;
_doctorAge = doctorage;
_doctorCity = doctorcity;
_doctorDesc = doctordesc;
}
}
而下面的代碼是用於將數據添加到列表
從集合中刪除: -
List<DoctorsData> doctorlist = new List<DoctorsData>();
doctorlist.Add(new DoctorsData("mukesh", "32","sirsa","aclass"));
doctorlist.Add(new DoctorsData("rajesh", "29","hisar","bclass"));
doctorlist.Add(new DoctorsData("suresh", "25","bangalore","cclass"));
doctorlist.Add(new DoctorsData("vijay", "24","bangalore","cclass"));
doctorlist.Add(new DoctorsData("kumar anna", "40","trichi","aclass"));
我的要求是我要刪除年齡小於30歲的所有醫生條目。我們可以如何使用LINQ執行此操作。
感謝此代碼正在工作 –