Advertisement
Geralt1001

zad 6.3.1 6.3.2

Oct 23rd, 2016
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace mw61
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.  
  15.             //var anonim = 1;
  16.             //anonim = new { Name = "Dynamiczny", Value = 10 };
  17.             object obiekt = 1;
  18.             dynamic dyn = 1;
  19.             //dyn = new { Name = "Dynamiczny", Value = 10 };
  20.             dyn = null;
  21.             //dyn.TreleMorele();
  22.  
  23.             //System.Console.WriteLine("{0} - {1}",dyn.Name, dyn.Value);
  24.             //System.Console.WriteLine("{0} - {1}", anonim.Name, anonim.Value);
  25.  
  26.             //MyDel Del = new MyDel(WriteToConsol);
  27.             //Del += WriteToFile;
  28.  
  29.             //Del("aaaaa");
  30.             //Info(Del);
  31.  
  32.             Info(delegate(string x) {
  33.                 Console.WriteLine("pierwsze wywołanie za pomoca anonimowego delegata");
  34.             });
  35.  
  36.             Info((string x)=>
  37.                 Console.WriteLine("drugie wywołanie za pomoca wyrażenia lambda")
  38.             );
  39.  
  40.             System.Console.ReadKey();
  41.         }
  42.         public delegate void MyDel(string text);
  43.  
  44.         private static void WriteToConsol(string text)
  45.         {
  46.             System.Console.WriteLine(text);
  47.         }
  48.  
  49.         private static void WriteToFile(string text)
  50.         {
  51.             System.Console.WriteLine("zapis do pliku: " + text);
  52.         }
  53.  
  54.         public static void Info(MyDel del)
  55.         {
  56.             del("Info about:");
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement