

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Get an ICollection containing the keys in ListDictionary in C#
To get an ICollection containing the keys in ListDictionary, the code is as follows −
Example
using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ ListDictionary listDict = new ListDictionary(); listDict.Add("1", "Laptop"); listDict.Add("2", "Tablet"); listDict.Add("3", "Desktop"); listDict.Add("4", "Speaker"); listDict.Add("5", "Earphone"); listDict.Add("6", "Headphone"); ICollection col = listDict.Keys; foreach(String s in col){ Console.WriteLine(s); } } }
Output
This will produce the following output −
1 2 3 4 5 6
Example
Let us see another example −
using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main(){ ListDictionary listDict = new ListDictionary(); listDict.Add("A", "Tom"); listDict.Add("B", "John"); listDict.Add("C", "Kevin"); listDict.Add("D", "Tim"); ICollection col = listDict.Keys; foreach(String s in col){ Console.WriteLine(s); } } }
Output
This will produce the following output −
A B C D
- Related Questions & Answers
- Get an ICollection containing the values in ListDictionary in C#
- Get an ICollection containing the keys in the Hashtable C#
- Get an ICollection containing the keys in HybridDictionary in C#
- Get an ICollection containing keys in OrderedDictionary in C#
- Get an ICollection containing the values in OrderedDictionary in C#
- Get an ICollection containing the values in HybridDictionary in C#
- Gets an ICollection containing the values in the Hashtable in C#
- Get an enumerator that iterates through the ListDictionary in C#
- How to get Synchronize access to the ListDictionary in C#?
- Get the number of key/value pairs contained in ListDictionary in C#
- ListDictionary Class in C#
- Get or set the value associated with specified key in ListDictionary in C#
- What does the interface ICollection do in C#
- Get a collection of keys in the StringDictionary in C#
- Remove all entries from the ListDictionary in C#
Advertisements