Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace ConsoleApp3
- {
- class Program
- {
- static void Main(string[] args)
- {
- Dictionary<string, int> allMaterial = new Dictionary<string, int>();
- allMaterial.Add("Glass", 1);
- allMaterial.Add("Aluminium", 2);
- allMaterial.Add("Lithium", 1);
- allMaterial.Add("Carbon fiber", 1);
- int count = 0;
- foreach (var kvp in allMaterial.OrderBy(x => x.Key))
- {
- if (kvp.Value > 0)
- {
- count++;
- }
- }
- Console.WriteLine(count);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement