C#とC++/CLIとVBと.NETとWindowsで戯れる
string [] ss = xxxx;List<string> NewList = new List<string>(ss);NewList.Sort(new Comparison<string>( delegate(string x, string y) { return string.Compare(x, y); }));
これが1つのパターンになるかな。
投稿日時 : 2006年2月10日 1:02
string [] ss = xxxx; List<string> NewList = new List<string>(ss); NewList.Sort(new Comparison<string>(string.Compare)); の方が...。
string は IComparable を実装してるから NewList.Sort(); だけで、、、とかってことじゃなくてパターンとしての一例なんですよね? C# 2.0 からは delegate がコンパイル時に推測可能なときは明示しなくてもよくなったので NewList.Sort(delegate(string x, string y) { ... }); で大丈夫です。 もちろん、 NewList.Sort(string.Compare); とも書けます。
ああ、new Comparison もいらんかったですね。orz ほんとのソース FileInfo[] NewFiles = this.NewDirInfo.GetFiles(); List<FileInfo> NewFileList = new List<FileInfo>(NewFiles); NewFileList.Sort( delegate(FileInfo x, FileInfo y) { return string.Compare(x.Name, y.Name); });
You saved me a lot of hsalse just now.
Would you like a cup of tea? Columbus discovered America in l492.Her family are all music lovers.The play may begin at any moment.Here's a gift for you.The number 13 bus will take you to the hospital.The whole world knows that.How did the game turn out?Japan is to the east of China.I'm doing some washing and John is cooking dinner
Powered by: Copyright © 中博俊