

- 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 or set the value associated with specified key in ListDictionary in C#
To get or set the value associated with specified key 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 dict = new ListDictionary(); dict.Add("A", "Books"); dict.Add("B", "Electronics"); dict.Add("C", "Appliances"); dict.Add("D", "Pet Supplies"); dict.Add("E", "Clothing"); dict.Add("F", "Footwear"); Console.WriteLine("Value associated with key C = "+dict["C"]); } }
Output
This will produce the following output −
Value associated with key C = Appliances
Example
Let us see another example −
using System; using System.Collections; using System.Collections.Specialized; public class Demo { public static void Main() { ListDictionary dict = new ListDictionary(); dict.Add("A", "Books"); dict.Add("B", "Electronics"); dict.Add("C", "Appliances"); dict.Add("D", "Pet Supplies"); dict.Add("E", "Clothing"); dict.Add("F", "Footwear"); Console.WriteLine("Value associated with key C = "+dict["C"]); dict["C"] = "HDD"; Console.WriteLine("Value associated with key C [Updated] = "+dict["C"]); } }
Output
This will produce the following output −
Value associated with key C = Appliances Value associated with key C [Updated] = HDD
- Related Questions & Answers
- Get or set the value associated with specified key in SortedList in C#
- Get or Set the value associated with specified key in Hashtable in C#
- Get or set the value associated with the specified key in StringDictionary in C#
- Add the specified key and value into the ListDictionary in C#
- Remove the entry with specified key from ListDictionary in C#
- Get the value associated with a given key in Java HashMap
- Get the number of key/value pairs contained in ListDictionary in C#
- Gets or sets the value in HybridDictionary with specified key in C#
- Modify the value associated with a given key in Java HashMap
- How to get the value associated with the http-equiv or name attribute in HTML?
- Gets or sets the value at the specified key in StringDictionary in C#
- Get or Set at specified index in StringCollection in C#
- Get or set the element at specified index in Collection in C#
- Get or set the element at the specified index in ArrayList in C#
- Adding the specified key and value into HybridDictionary in C#
Advertisements