using Mono.CSharp; ...... ParametersCompiled params = new ParametersCompiled (); params.Add (new Parameter (new TypeExpression (new SimpleType ("int")), "x")); params.Add (new Parameter (new TypeExpression (new SimpleType ("string")), "y"));
using Mono.CSharp; ...... ParametersCompiled params = new ParametersCompiled (); params.Add (new Parameter (new TypeExpression (new SimpleType ("float")), "radius")); MethodInfo methodInfo = typeof (Circle).GetMethod ("CalculateArea"); if (methodInfo == null) Console.WriteLine ("Method does not exist"); else { Object obj = Activator.CreateInstance (typeof (Circle)); double area = (double) methodInfo.Invoke (obj, new object[] { 4.5f }); Console.WriteLine ("Area of circle is: " + area); }In this example, we create a new instance of the ParametersCompiled class and add a float parameter named "radius". We then use a reflection to get the method info for a method named "CalculateArea" in a class named "Circle". We then create an instance of the "Circle" class and invoke the "CalculateArea" method with the parameter value of 4.5f. Finally, we print out the calculated area. Package Library: The ParametersCompiled class is a part of the Mono.CSharp package library.