S
Swapnil
As we know we can call function from the class by using object of the class
where that function is present.
Then what is new in delegate it also calls the function but the difference
is that we are providing wrapper around the function call. iI know it is
typesafe. Explain with some strong cocept(reason).
Then why we should use Delegate?
e.g.
Suppose i have function in Myclass class
class Myclass{ void Add (int a){}}
To call this function i will use object of Myclass.
Myclass objMyclass=new Myclass();
objMyclass.Add(4);
like this i can call the function.
But by using delegate
delegate void Delegatename(int x); //definition of dlegate
Delegatename objDelegate=new Delegatename(objMyclass.Add(4));
so by using delegate we r giving overheads then why we should use delegate?
where that function is present.
Then what is new in delegate it also calls the function but the difference
is that we are providing wrapper around the function call. iI know it is
typesafe. Explain with some strong cocept(reason).
Then why we should use Delegate?
e.g.
Suppose i have function in Myclass class
class Myclass{ void Add (int a){}}
To call this function i will use object of Myclass.
Myclass objMyclass=new Myclass();
objMyclass.Add(4);
like this i can call the function.
But by using delegate
delegate void Delegatename(int x); //definition of dlegate
Delegatename objDelegate=new Delegatename(objMyclass.Add(4));
so by using delegate we r giving overheads then why we should use delegate?