lundi 7 août 2017

How to get input and return type of delegate stored in list

I want to create list of method. and run this list of method in order. The input of next method is output of current method.

So, this is my code for these, and i need to get input, output type.

static void Main( string [ ] args )
{
    List<dynamic> temp = new List<dynamic>();

    Func<int,int> fn1 = new Func<int,int>( x => 3); 
    Func<int,int> fn2 = new Func<int,int>(x  => x + 3);
    Func<int,int> fn3 = new Func<int,int>(x  => x + 30);
    Func<int,double> fn4 = new Func<int,double>(x  => x*0.2);

    temp.Add( fn1 ); 
    temp.Add( fn2 );
    temp.Add( fn3 );
    temp.Add( fn4 );

    int input = 6;
    // use for or foreach or something 
    // output ?
}





Aucun commentaire:

Enregistrer un commentaire