Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections.Generic;
- using System.Linq;
- namespace kartka6
- {
- // zadanie 1
- // a) metoda która bedzie moliwa do wywolania bez tworzenia obiektu
- // b) przyjmuję zmienną liczbę słownikow na wzór słownika polsko-angielskiego
- // c) zwraca slownik będący polączeniem wszystkich słownikówprzekazanych do metody
- class Program
- {
- static void Main(string[] args)
- {
- f1("lala");
- Dictionary<string, string> dic = new Dictionary<string, string>();
- dic.Add("Cat", "kot");
- dic.Add("Dog", "pies");
- Dictionary<string, string> dic2 = new Dictionary<string, string>();
- dic2.Add("House", "dom");
- dic2.Add("Garden", "ogród");
- f2(dic, dic2);
- var newDic1 = f3(dic,dic2);
- foreach(KeyValuePair<string, string> zm in newDic1)
- {
- Console.WriteLine("Key = {0}, Value = {1}", zm.Key, zm.Value);
- }
- }
- public static void f1(string s)
- {
- Console.WriteLine("Text: "+s);
- }
- public static void f2(params Dictionary<string, string> [] dic)
- {
- for(int i=0; i< dic.Length; i++)
- {
- foreach(KeyValuePair<string, string> zm in dic[i])
- {
- Console.WriteLine("Key = {0}, Value = {1}", zm.Key, zm.Value);
- }
- }
- }
- public static Dictionary<string, string> f3(params Dictionary<string, string> [] dic)
- {
- Dictionary<string, string> newDic = new Dictionary<string, string>();
- for(int i=0; i< dic.Length; i++)
- {
- foreach(KeyValuePair<string, string> zm in dic[i])
- {
- newDic.Add(zm.Key, zm.Value);
- }
- }
- return newDic;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement