Not quite sure how using built-in types is any different from user created types. Your bigger problem would creating instances of types that don't have parameterless constructors.
Whatever you do, you will have to cast those into object arrays so you can pass them to MethodInfo.Invoke
, so at some point you will need to do Activator.CreateInstance
.
If you provide a UI where a user can enter stuff in fields and then press a button to call a method, you best strategy would be to use Reflection to look for the TryParse/Parse static methods on the type and call those in order to validate/parse the input.
Here is a snippet that will work implicitly for most system types that can be converted from string:
var parseMethod = typeof(int).GetMethods().FirstOrDefault(
m => m.IsStatic &&
m.Name == "TryParse" &&
m.GetParameters().Length == 2 &&
m.GetParameters()[0].ParameterType == typeof(string) &&
m.GetParameters()[1].IsOut);
if(parseMethod != null) {
bool result = (bool)parseMethod.Invoke(null, new object[]{"45", null});
//result == true
result = (bool)parseMethod.Invoke(null, new object[] { "blah", null });
//result = false
}