Advertisement
Guest User

Untitled

a guest
Oct 21st, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. namespace Rextester
  2. {
  3.     public class Program
  4.     {
  5.         public static void Main(string[] args)
  6.         {
  7.            ExtendedDictionary<int> dic = new ExtendedDictionary<int>();
  8.             dic.Insert(1, "lala");
  9.             dic.Insert(2, "dydy");
  10.             int zm = dic.Suum();
  11.             Console.WriteLine(zm);
  12.         }
  13.     }
  14.    
  15.     public class ExtendedDictionary<T> where T :
  16.     {      
  17.         private Dictionary<T, string> items;
  18.         private int sum ;
  19.        // public int Sum{  get { return sum;} }
  20.        // public int Sum{ get; set;}
  21.        
  22.         public ExtendedDictionary()
  23.         {
  24.             items = new Dictionary<T, string>();
  25.         }
  26.          
  27.         public void Insert(T key, string valuee)
  28.         {
  29.             items.Add(key, valuee );
  30.         }
  31.        
  32.         public void Delete(T key)
  33.         {
  34.             items.Remove(key);
  35.         }
  36.        
  37.         public int Suum()
  38.         {
  39.             return items.Sum(e => e.Value.Length);
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement