Exemplo n.º 1
0
        public void person(delegat q)
        {
            //  Console.WriteLine(q("Ahemd", 13));
            Console.Write("$Person2$");

            q("Ahemd", 13);
        }
Exemplo n.º 2
0
        private void delegaty(object sender, EventArgs e)
        {
            int n = int.Parse(textBox1.Text);
            int k = int.Parse(textBox2.Text);

            timer1.Start();
            delegat funkcja = new delegat(liczDelegaty);

            funkcja.BeginInvoke(n, k, null, null);
        }
Exemplo n.º 3
0
 public Wartosc(float cena, float wartoscSentymentalna, delegat eventHandler)
 {
     if (cena < 0.0f || wartoscSentymentalna < 0.0f)
     {
         throw new ValidationException("wartość i cena nie mogą być mniejsze niż 0 PLN");
     }
     this.cena = cena;
     this.wartoscSentymentalna = wartoscSentymentalna;
     this.wzrostWartosciEvent  = eventHandler;
 }
Exemplo n.º 4
0
        public IEnumerable <Par <Kljuc, Vrednost> > Filtriraj(delegat fja)
        {
            List <Par <Kljuc, Vrednost> > lista = new List <Par <Kljuc, Vrednost> >();

            foreach (var item in parovi)
            {
                if (fja(item) == true)
                {
                    lista.Add(item);
                }
            }
            return(lista);
        }
Exemplo n.º 5
0
    static void Main()
    {
        // {
        dele d = new dele();
//   //  delegat q = new delegat("medo", 20); // must take a method
//     delegat w;
        //d.citizen("medo", 23);
//     w = d.citizen;
//     d.person("aya", 88);
//     w = d.person; Console.WriteLine("_______________________________________\n\n");
////   w=new delegat(d.citizen("tiger",90)); //  لايجوز تعريف الميثود وضع قيم داخل الديلجيت .
        // pass delegate as parameter

        delegat q  = new delegat(d.citizen);
        delegat qq = new delegat(d.person);

        q("mgdy", 83);
        d.person(qq); Console.WriteLine(); // takes from delete qq from person
        d.person(q);                       // takes from delete q from citizen
    }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            test           = new delegat(factorial);
            test_recursion = new delegat(factorial_recursion);
            IAsyncResult ar  = test_recursion.BeginInvoke(40, callback, new object[] { 35, 1 });
            IAsyncResult arr = test.BeginInvoke(40, callback, new object[] { 35, 2 });

            long result_recursion = test_recursion.EndInvoke(ar);
            long result           = test.EndInvoke(arr);



            test2           = new delegat(fibonacci);
            test_recursion2 = new delegat(fibonacci_recursion);
            IAsyncResult arrr  = test_recursion.BeginInvoke(40, callback, new object[] { 90, 3 });
            IAsyncResult arrrr = test.BeginInvoke(40, callback, new object[] { 90, 4 });

            result_recursion = test_recursion.EndInvoke(arrr);
            result           = test.EndInvoke(arrrr);

            Thread.Sleep(4000);
        }
        static void Main(string[] args)
        {
            Animals.DoAnimal();

            Woman w1 = new Woman("Woman");
            Man   m1 = new Man("Man");
            Dog   d1 = new Dog();

            delegat del1 = new delegat(w1.GetVoice);
            delegat del2 = new delegat(m1.GiveVoice);
            delegat del3 = new delegat(d1.Describe);

            del1("\nwoman voice");
            del2("man voice");
            del3("dog describe\n");

            delegat del4 = new delegat(d1.Describe);

            del4 += m1.GiveVoice;
            del4 += d1.Describe;

            del4("woman voice, man voice, dog describe");
        }
Exemplo n.º 8
0
 public Car(string name, delegat handler) : base(name, handler)
 {
 }
Exemplo n.º 9
0
 private void ColorEvent(object sender, EventArgs e)
 {
     buttonClickEvent = change_background;
     buttonClickEvent();
 }
Exemplo n.º 10
0
 private void OpacityEvent(object sender, EventArgs e)
 {
     buttonClickEvent = change_opacity;
     buttonClickEvent();
 }
Exemplo n.º 11
0
 private void btn_text_Click(object sender, EventArgs e)
 {
     buttonClickEvent = text;
     buttonClickEvent();
 }
Exemplo n.º 12
0
 private void btn_Transparency_Click(object sender, EventArgs e)
 {
     buttonClickEvent = change_opacity;
     buttonClickEvent();
 }
Exemplo n.º 13
0
 private void MessageEvent(object sender, EventArgs e)
 {
     buttonClickEvent = text;
     buttonClickEvent();
 }
Exemplo n.º 14
0
 public Zabawka(string name, delegat handler)
 {
     this.name          = name;
     this.wartoscBazowa = new Wartosc(10.0f, 1.0f, handler);
 }