看来我偶然发现了LINQ并且只是设法看到了它的用处.我不确定我是否要求太多,或者我是不是做得不对.我有以下笨拙的代码,
class CStation{
public String Make;
public List<ulong> TunedStations;
}
List<List<ulong>> mStations=(from t in Radios where t.Make==aMake select t.TunedStations).ToList();
if(mStations.Count!=0)
return mStations[0];
return null;
Run Code Online (Sandbox Code Playgroud)
功能是的,但我可以用LINQ怎么做?
只是用
return (from t in Radios where t.Make==aMake select t.TunedStations).FirstOrDefault();
Run Code Online (Sandbox Code Playgroud)