Delegate Array in C#

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5.    
  6. namespace ArrayDelegates  
  7. {  
  8.    public delegate string Delegatearray(string a);  
  9.    
  10.    class Delegate_Array  
  11.    {  
  12.       static string Str_Reverse(string x)  
  13.        {  
  14.            string S = new string(x.ToCharArray().Reverse().ToArray());  
  15.            return S;  
  16.        }  
  17.    
  18.        static string Str_Length(string x)  
  19.        {  
  20.          string S = Convert.ToString(x.Length);  
  21.          return S;  
  22.        }  
  23.          
  24.        static void Main(string[] args)  
  25.        {  
  26.            string call;  
  27.            Delegatearray[] Darray = { new Delegatearray(Delegate_Array.Str_Reverse),  
  28.                                                           new Delegatearray(Delegate_Array.Str_Length) };  
  29.            for (int i = 0; i < Darray.Length; i++)  
  30.            {  
  31.                 call=Darray[i]("C-SHARP");  
  32.                 Console.WriteLine(call);  
  33.            }  
  34.                Console.ReadKey();  
  35.         }  
  36.     }  
  37. }