2.8k views
2 votes
Perform the Insert, Modify and Remove functionalities on the Dictionary based on the Key.

1 Answer

3 votes

Answer:

Dictionary contains Key value pairs where key is used to retrieve the value

Step-by-step explanation:

Using System.Collections;

void main(){

Dictionary<int, string> dict = new Dictionary<int, string>();

dict.Add(1,"One");

dict.Add(2,"Two");

dict.Add(3,"Three");

dict.Remove(1);

dict[2] = "Two Updated";

}

Dictionary<int, string> is a dictionary whose keys are integers and values are strings.

Add function is used to add elements to the dictionary

Remove function removes the key value pair from the dictionary based on given key.

we can directly modify/update the element in dictionary using the key

User Jonathan Arbogast
by
6.4k points