How to

循环中移除集合项

//you can work around the limitation by creating a new collection dynamically to hold the enumerated collection. 
foreach (string s in new System.Collections.ArrayList(arr)) //for read
            {
                arr.Remove(s); //for write
            }

 

生成唯一序列

Enumerable.Range(1, 100).OrderBy(x => rnd.Next())

 

获取程序集中特定接口的所有实例

return AppDomain.CurrentDomain.GetAssemblies().SelectMany(a => a.GetTypes().Where(t => t.GetInterfaces().Contains(typeof(IModuleInit))));

 

自定义排序

            stations.Sort((a, b) => string.Compare(a.DisplayName, b.DisplayName));

 

  

posted @ 2020-09-03 11:48  yetsen  阅读(457)  评论(0编辑  收藏  举报