
- C# Basic Tutorial
- C# - Home
- C# - Overview
- C# - Environment
- C# - Program Structure
- C# - Basic Syntax
- C# - Data Types
- C# - Type Conversion
- C# - Variables
- C# - Constants
- C# - Operators
- C# - Decision Making
- C# - Loops
- C# - Encapsulation
- C# - Methods
- C# - Nullables
- C# - Arrays
- C# - Strings
- C# - Structure
- C# - Enums
- C# - Classes
- C# - Inheritance
- C# - Polymorphism
- C# - Operator Overloading
- C# - Interfaces
- C# - Namespaces
- C# - Preprocessor Directives
- C# - Regular Expressions
- C# - Exception Handling
- C# - File I/O
- C# Advanced Tutorial
- C# - Attributes
- C# - Reflection
- C# - Properties
- C# - Indexers
- C# - Delegates
- C# - Events
- C# - Collections
- C# - Generics
- C# - Anonymous Methods
- C# - Unsafe Codes
- C# - Multithreading
- C# Useful Resources
- C# - Questions and Answers
- C# - Quick Guide
- C# - Useful Resources
- C# - Discussion
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 Articles
- Get or Set the value associated with specified key in Hashtable in C#
- Get or set the value associated with specified key in SortedList 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#
- How to Get Value from HashTable Collection in C# using Specified Key
- Get or set the element at the specified index in ArrayList in C#

Advertisements