Skip to main content

Working with delegates c#

Delegates

Delegates are the pointers for the functions. The most amazing part of delegates is that you can point more than one function at a time and can call those functions from just one statement. The sequence of the function calling depends upon the sequence in which one adds the functions to the delegate.

Lets see an example.

using System;
namespace deligate
{
    class Program
    {public delegate int addDeligate(int a, int b);
        static void Main(string[] args)
        {
            addDeligate d1 = new addDeligate(add);
            Console.WriteLine(d1(3, 2));
            Console.ReadLine();
        }
        public static int add(int a,int b)
        {
            return a + b;
        }
    }
}

Comments

Popular posts from this blog

Theory of Automata Assignment #2 Part #2 Regular Expression # 6 The set of strings over {a,b} that contain at least two a's or exactly two b's. (a+b)*(a)(b*)a(a+b)*+a*b(a*)b(a*) Regular Expression # 7 The set of strings over {a,b} that contain even length but not multiple of 3 (aa*)(aaa^) Regular Expression # 8 The language over {a,b}contains exactly one double letter.   (ε + b)(ab) ∗aa(ba) ∗(ε + b) + (ε + a)(ba) ∗ bb(ab) ∗(ε + a)

TA ASSIGNMENT 1 PART 3

Theory of Automata Assignment #1 Part #3 Recursive Definition #11: Language of Expressions having at least one operator defined on  Σ ={+,-,*,/,a,b}  Step 1#- a+b ,a*b,a/b and a-b are in L Step 2#- If x is in L then x+x,x-x,x*x,x/x is also in L Step 3#- No words except generated above can be considered as member of Language. Recursive Definition #12: Language of string starting and ending on different alphabet defined on  Σ ={a,b} Step 1#- ab and ba are in L Step 2#- If x is in L then axb,and bxa are also in  Σ*.   Step 3#- No words except generated above can be considered as member of Language. Recursive Definition #13: Language of even numbers Step 1#- 0 and 2 are in L Step 2#- If x is in L then x+2 and x-2 is also in L .   Step 3#- No words except generated above can be considered as member of Language. Recursive Definition #14: Language of negative integers d...

Generations of Computer Part 1

Hello azumavenger  and  welcome to my blog. Today we are going to talk about the computer generations Computer Machine and Their Generations As we all know Computer is an electronic machine which solve different calculations precisely, accurately, in short span of time and more efficiently. Now the question is that why was such thing invented in first place. Humans are more intelligent than computers, they can make decisions and can conquer many things on the base of feelings then why was computer needed. The answer is simple to save human from labor work. Computers were nothing like what they are today The PC's to be precise Personal Computers we use today were not this efficient and cool back in John Mauchly's days. They were big, they consumed more power and were not easy to use. Diving deep, computer machines evolved from different versions to become what they are today, It started from ENIAC and is still being updated. Actually around 4 generations h...