C#: Return IEnumerable when field is not null?
问题 public IEnumerable GetAddress() { DataSet ds = DataOps.GetDataSet(string.Format(" select * from Students")); DataTable dt = ds.Tables[0]; // What goes here? } I need to use IEnumerable methods How can i return enumeration of DataRows containing all students that have addresses only? 回答1: I think what you are looking is DataRow[] dr = ds.Tables[0].Select("Address NOT NULL"); // you want filtering on address column foreach (DataRow row in dr) { } 回答2: I don't know what your student class looks