grady
grady

Reputation: 12755

Create a List<string> from HashTable keys?

Hey, how could I do this as short as possible?

Thanks :-)

Upvotes: 5

Views: 8674

Answers (1)

Florian Reischl
Florian Reischl

Reputation: 3856

Try this:

System.Collections.Hashtable ht = new System.Collections.Hashtable();
List<string> list = ht.Keys.Cast<string>().ToList();

Upvotes: 10

Related Questions