Advertisement
KodingKid

C# car dictionary (FIAT, Ferrari, Trabant)

Mar 30th, 2021
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. IDictionary<int, string> numberNames = new Dictionary<int, string>();
  2. numberNames.Add(1,"One");
  3. numberNames.Add(2,"Two");
  4. numberNames.Add(3,"Three");
  5. foreach(KeyValuePair<int, string> kvp in numberNames)
  6.     Console.WriteLine("Key: {0}, Value: {1}", kvp.Key, kvp.Value);
  7. var cars = new Dictionary<string, string>(){
  8.     {"FIAT", "FIAT Topolino, FIAT 500, FIAT 600, FIAT Cinquecento, FIAT 126"},
  9.     {"Ferrari", "Ferrari 166 Inter, Ferrari 250 GT/E, Ferrari California T, Ferrari Berlinetta Boxer 365 GT/4 BB, Ferrari Dino 206 GT"},
  10.     {"Trabant", "Trabant P50, Trabant 600, Trabant 601, Trabant 1.1, Trabant 800RS"}
  11. }; 
  12. foreach(var kvp in cars)
  13.     Console.WriteLine("Key: {0}, Value: {1}," kvp.Key, kvp.Value);
  14. Console.WriteLine(cars["FIAT"]);
  15. Console.WriteLine(cars["Ferrari"]);
  16. Console.WriteLine(cars["Trabant"]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement