1. WeatherInfo 리스트에서 LINQ 사용하여 검색하기
public IList<WeatherInfo> GetWeatherInfoListByTemperatureRange(double min, double max)
{
IList<WeatherInfo> tList = (from w in wList where (w.AverageTemperature >= min && w.AverageTemperature <= max) orderby w select w).ToList();
return tList;
}
{
IList<WeatherInfo> tList = (from w in wList where (w.AverageTemperature >= min && w.AverageTemperature <= max) orderby w select w).ToList();
return tList;
}
2. WeatherInfo 리스트에서 FindAll과 delegate 사용하여 검색하기
public IList<WeatherInfo> GetWeatherInfoListByTemperatureRange2(double min, double max)
{
IList<WeatherInfo> tList = wList.FindAll(delegate(WeatherInfo w)
{ return (w.AverageTemperature >= min && w.AverageTemperature <= max); });
return tList;
}
{
IList<WeatherInfo> tList = wList.FindAll(delegate(WeatherInfo w)
{ return (w.AverageTemperature >= min && w.AverageTemperature <= max); });
return tList;
}