Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
CheckedListBox.CheckedItemsStringListとして取得しようとしています。しかし、私はそれを取得する方法がわかりません。LINQを使用してワンライナーとして作成しようとしています。.Net-C#での私の不十分な経験では、それを行うことはできません。誰かがそれを行う方法を言うことができますか?
CheckedListBox.CheckedItems
注:私は.Net-4.0を使用しています。
これらのアイテムに保存した値が文字列の場合:
List<string> items = chk.CheckedItems.Cast<string>().ToList();
それらがカスタムタイプの場合、そのタイプを使用できます:
List<SomeTypeUsedForTheItems> items = chk.CheckedItems.Cast<SomeTypeUsedForTheItems>().ToList();