using System.Collections.Generic;
public Number(List<object> args)
intMethod = args[0] as Func<int, int>;
floatMethod = args[2] as Func<float, float, float>;
float1 = Convert.ToSingle(args[3]);
float2 = Convert.ToSingle(args[4]);
private Func<int, int> intMethod;
private Func<float, float, float> floatMethod;
private float float1 = 1;
private float float2 = 1;
public float NumberTest()
return (float)intMethod.Invoke(int1) + floatMethod.Invoke(float1, float2);
public Text(List<object> args)
stringMethod = args[0] as Func<string, string>;
string1 = args[1].ToString();
private Func<string, string> stringMethod;
private string string1 = "";
return string.Format("{0} is great !", stringMethod.Invoke(string1));
public Demo(List<object> args)
number = new Number(args[0] as List<object>);
text = new Text(args[1] as List<object>);
return string.Format("{0}, {1}", number.NumberTest(), text.TextTest());
public static void Main()
Func<int, int> triple = i => i * 3;
Func<float, float, float> plus = (x, y) => x + y;
Func<string, string> upper = s => s.ToUpper();
List<object> args = new List<object>() { new List<object>() { triple, 3, plus, 4, 5 }, new List<object>() { upper, "Nick" } };
Demo demo = new Demo(args);
Console.WriteLine(demo.DemoTest());
Func<int, int> doub = i => i * 2;
Func<float, float, float> minus = (x, y) => x - y;
Func<string, string> lower = s => s.ToLower();
demo = new Demo(new List<object>() { new List<object>() { doub, 3, minus, 4, 5 }, new List<object>() { lower, "Nick" } });
Console.WriteLine(demo.DemoTest());