30
1
using System;
2
using System.Collections.Generic;
3
4
public class Program
5
{
6
public static void Main()
7
{
8
var cities = new Dictionary<string, string>(){
9
{"UK", "London, Manchester, Birmingham"},
10
{"USA", "Chicago, New York, Washington"},
11
{"India", "Mumbai, New Delhi, Pune"}
12
};
13
14
Console.WriteLine("Total Elements: {0}", cities.Count);
15
16
cities.Remove("UK"); // removes UK
17
//cities.Remove("France"); //throws run-time exception: KeyNotFoundException
18
19
if(cities.ContainsKey("France")){ // check key before removing it
20
cities.Remove("France");
21
}
22
23
Console.WriteLine("Total Elements: {0}", cities.Count);
24
25
cities.Clear(); //deletes all elements
26
27
Console.WriteLine("Total Elements after Clear(): {0}", cities.Count);
28
29
}
30
}
Cached Result
Programa par calcular promedio de notas
Digite el nombre del alumno
>
Digite el nombre del alumno