Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- namespace DemoDictionary
- {
- internal class Program
- {
- static void Main(string[] args)
- {
- //ученик -> оценка
- Dictionary<string, double> students = new Dictionary<string, double>();
- students.Add("Pesho", 5.60);
- students.Add("Niki", 3.40);
- students.Add("Ivan", 5.40);
- //Pesho -> 5.60
- //Niki -> 3.40
- //Ivan -> 5.40
- students.Remove("Ivan");
- //Pesho -> 5.60
- //Niki -> 3.40
- Console.WriteLine(students.ContainsKey("Desi")); //False
- Console.WriteLine(students.ContainsKey("Pesho")); //True
- Console.WriteLine(students.ContainsValue(3.40)); //True
- Console.WriteLine(students.ContainsValue(6.70)); //False
- Console.WriteLine(students.Count); //брой на записи в речника
- Console.WriteLine(students["Pesho"]); //5.60
- students["Niki"] = 5.90;
- //Pesho -> 5.60
- //Niki -> 5.90
- Console.WriteLine(students["Niki"]); //5.90
- students["Petar"] = 4.70;
- //Pesho -> 5.60
- //Niki -> 5.90
- //Petar -> 4.70
- students.Clear(); //премахне всички записи в речника
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment