您的位置:首页 > 其它

一个提醒...such as implement System.Collections.Generic.IComparer<T>

2009-08-17 00:25 399 查看
Like this:

1 L.Sort(delegate(int a, int b)
2IEnumerable<int> myUsers = al.Cast<int>();

Then can use linq to do the things we need with myUsers
But sometimes this may throw exceptions...because not every item can cast to the TResult
Then we can use ofType<T>....
It will ignore the items which can't cast to TResult

2. Also can do it like this:

1 DAL demo = new DAL("");
2 L.Sort(demo.Compare);

with the DAL below:

1 class DAL : System.Collections.Generic.IComparer<int>
2 {
3{
7 return (y - x);
8 }
9
10 #endregion
11 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐