[過去ログ]
ふらっと C#,C♯,C#(初心者用) Part154 (1002レス)
ふらっと C#,C♯,C#(初心者用) Part154 http://mevius.5ch.net/test/read.cgi/tech/1644416019/
上
下
前次
1-
新
通常表示
512バイト分割
レス栞
抽出解除
必死チェッカー(本家)
(べ)
自ID
レス栞
あぼーん
このスレッドは過去ログ倉庫に格納されています。
次スレ検索
歴削→次スレ
栞削→次スレ
過去ログメニュー
695: デフォルトの名無しさん (ワッチョイ 5b66-jfEb) [] 2022/06/02(木) 20:53:08.53 ID:UucOdGXH0 Findが速いらしいので下記のようにプログラムしました。 実測してfor文との速さを比べてみたいと思います。 public class TestItem { public string x; public string y; } private static void Test() { var list = new List<TestItem>(); list.Add(new TestItem() { x = "a", y = "a1" }); list.Add(new TestItem() { x = "b", y = "b1" }); list.Add(new TestItem() { x = "c", y = "c1" }); string n = string.Empty; list.Find(item => { if (item.x == "b") { n = item.y; return true; } return false; }); Console.WriteLine(n); } http://mevius.5ch.net/test/read.cgi/tech/1644416019/695
698: デフォルトの名無しさん (ワッチョイ 5b66-jfEb) [] 2022/06/02(木) 21:31:15.89 ID:UucOdGXH0 さらに調べたらDictionaryが検索最強のようなので、Dictionaryを 使おうと思います。 var table = new Dictionary<string, string> { { "n01" , "a" }, { "n02" , "b" }, { "n03" , "c" }, { "n04" , "d" }, { "n05" , "e" }, { "n06" , "f" }, }; var result2 = ""; table.TryGetValue("n04", out result2); Console.WriteLine(result2); http://mevius.5ch.net/test/read.cgi/tech/1644416019/698
メモ帳
(0/65535文字)
上
下
前次
1-
新
書
関
写
板
覧
索
設
栞
歴
スレ情報
赤レス抽出
画像レス抽出
歴の未読スレ
Google検索
Wikipedia
ぬこの手
ぬこTOP
0.025s