Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get CheckedListBox.checkedItems as a stringlist

I am trying to get CheckedListBox.CheckedItems as a StringList. But I don't know how to get it. I am trying to make it as a one liner using LINQ. My insufficient experience in .Net-C# is not capable to do that. Can anybody say how to do that?

Note: I am using .Net-4.0.

like image 811
prabhakaran Avatar asked Aug 15 '12 09:08

prabhakaran


1 Answers

If the values you stored in those items are strings:

List<string> items = chk.CheckedItems.Cast<string>().ToList();

If they are of some custom type you could use that type:

List<SomeTypeUsedForTheItems> items = chk.CheckedItems.Cast<SomeTypeUsedForTheItems>().ToList();
like image 190
Darin Dimitrov Avatar answered Oct 22 '22 16:10

Darin Dimitrov