desislava_topuzakova

Demo: Sorted Dictionary

Mar 27th, 2022
908
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.95 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace DemoSortedDictionary
  5. {
  6.     internal class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             SortedDictionary<int, string> people = new SortedDictionary<int, string>();
  11.             //ключовете да са сортирани в ascending order (нарастващ ред)
  12.             people.Add(34, "Aleks");
  13.             people.Add(10, "Pesho");
  14.             people.Add(23, "Gosho");
  15.             //10 -> Pesho
  16.             //23 -> Gosho
  17.             //34 -> Aleks
  18.  
  19.             Console.WriteLine(people.Count);
  20.  
  21.             SortedDictionary<string, int> animals = new SortedDictionary<string, int>();
  22.             //ключовете да са сортирани в ascending order (азбучен ред) -> a към z
  23.             animals.Add("zebra", 1500);
  24.             animals.Add("elephant", 3500);
  25.             animals.Add("antilope", 700);
  26.         }
  27.     }
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment