foreach (var filter in filters)
{
var filterType = typeof(Filters);
var method = filterType.GetMethod(filter, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Static);
if (method != null)
{
var parameters = method.GetParameters();
Type paramType = parameters[0].ParameterType;
value = (string)method.Invoke(null, new[] { value });
}
}
How can I cast value
to paramType
? value
is a string
, paramType
will probably just be a basic type like int
, string
, or maybe float
. I'm cool with it throwing an exception if no conversion is possible.