YORDAN2347

DictinaryCommands

Apr 20th, 2021
533
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace _20._04._21
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             var students = new Dictionary<string, double>();
  12.  
  13.             students.Add("Георги", 3.5);
  14.             students.Add("Стефан", 4.5);
  15.             students.Add("Петър", 5);
  16.             students.Add("Цветан", 3.25);
  17.             students.Add("Христо", 4.75);
  18.             students.Add("Йордан", 6);
  19.  
  20.             Console.WriteLine($"Dictionary size is: {students.Count}");
  21.  
  22.             Console.WriteLine($"Георги mark: {students["Георги"]:f2}");
  23.  
  24.             students.Remove("Цветан");
  25.             Console.WriteLine($"Цветан removed");
  26.  
  27.             bool isTrue = students.ContainsKey("Йордан");
  28.             Console.WriteLine($"Is contains Йордан: {isTrue}");
  29.  
  30.             foreach (var student in students)
  31.             {
  32.                 Console.WriteLine($"Student Name: {student.Key}, Student Grade: {student.Value}");
  33.             }
  34.  
  35.             students.Clear();
  36.             Console.WriteLine($"Is Contains anything: {students.Any()}");
  37.         }
  38.     }
  39. }
  40.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×