Advertisement
angelneychev

Untitled

Jun 25th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp3
  6. {
  7.     class Program
  8.     {
  9.         static void Main(string[] args)
  10.         {
  11.             Dictionary<string, int> allMaterial = new Dictionary<string, int>();
  12.             allMaterial.Add("Glass", 1);
  13.             allMaterial.Add("Aluminium", 2);
  14.             allMaterial.Add("Lithium", 1);
  15.             allMaterial.Add("Carbon fiber", 1);
  16.             int count = 0;
  17.             foreach (var kvp in allMaterial.OrderBy(x => x.Key))
  18.             {
  19.                 if (kvp.Value > 0)
  20.                 {
  21.                     count++;
  22.                 }
  23.             }
  24.  
  25.             Console.WriteLine(count);
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement