using
System;
using
System.Collections.Generic;
class
Program
{
static
void
Main(
string
[] args)
{
List<KeyValuePair<
int
,
int
>> myList =
new
List<KeyValuePair<
int
,
int
>>();
myList.Add(
new
KeyValuePair<
int
,
int
>(1, 10));
myList.Add(
new
KeyValuePair<
int
,
int
>(2, 20));
myList.Add(
new
KeyValuePair<
int
,
int
>(3, 30));
Console.Write(
"Elements in the list: "
);
foreach
(
var
pair
in
myList)
{
Console.Write($
"({pair.Key}, {pair.Value}) "
);
}
Console.WriteLine();
int
firstElement = myList[0].Value;
int
secondElement = myList[1].Value;
myList[1] =
new
KeyValuePair<
int
,
int
>(2, 25);
for
(
int
i = 0; i < myList.Count; i++)
{
if
(myList[i].Value == 30)
{
myList.RemoveAt(i);
break
;
}
}
Console.Write(
"Updated list: "
);
foreach
(
var
pair
in
myList)
{
Console.Write($
"({pair.Key}, {pair.Value}) "
);
}
Console.WriteLine();
}
}