LoginSignup
2
1

More than 1 year has passed since last update.

C#のリストで、条件に一致するインデックスを取得する方法

Last updated at Posted at 2019-05-29

C#のリストで、条件に一致するインデックスを取得する方法

この目的にはFindIndexが使えます。

sampleListから、idが3の要素のインデックスを取得するには次のようにします。

var index = sampleList.FindIndex(sample => sample.id == 3);

その他の方法についてコメントもお待ちしております。
この記事が参考になれば幸いです。

終わりに

私は現在、Web3のサービスの開発をしています。詳しくはこちらの記事をご覧下さい。
無料でイーサリアムが当たる、Web3時代の寄付サイトを作った話

2
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1