using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace dotNet
{
class Greeting
{
public static int displayGanesh()
{
Console.WriteLine("Ganesh Here !!");
return 0;
}
public static int displayVishnu()
{
Console.WriteLine("Vishnu Here !!");
return 1;
}
}
delegate int delGreetings();
class Program
{
static void Main(string[] args)
{
int choice = 1;
delGreetings[] Greetings =
{
new delGreetings(Greeting.displayGanesh),
new delGreetings(Greeting.displayVishnu)
};
int return_ = Greetings[choice - 1]();
Console.Write("Return Value ");
Console.WriteLine(return_);
return;
}
}
}
delegate is basically defines the function pointer.
In the below snippet, it defines a function pointer which
takes no arguments and returns an int value.
delegate int delGreetings();
Happy Hacking !!
Sorry I have no knowledge of this coding as not an IT personel, however I am sure the info is very good.
ReplyDeletehttp://cutestangel.wordpress.com/