[過去ログ] ふらっと C#,C♯,C#(初心者用) Part154 (1002レス)
前次1-
抽出解除 必死チェッカー(本家) (べ) 自ID レス栞 あぼーん

このスレッドは過去ログ倉庫に格納されています。
次スレ検索 歴削→次スレ 栞削→次スレ 過去ログメニュー
695: デフォルトの名無しさん (ワッチョイ 5b66-jfEb) [] 2022/06/02(木) 20:53:08.53 ID:UucOdGXH0(1/2) AAS
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);
}
698: デフォルトの名無しさん (ワッチョイ 5b66-jfEb) [] 2022/06/02(木) 21:31:15.89 ID:UucOdGXH0(2/2) AAS
さらに調べたら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);
前次1-
スレ情報 赤レス抽出 画像レス抽出 歴の未読スレ AAサムネイル

ぬこの手 ぬこTOP 0.028s