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 });
}
}
Run Code Online (Sandbox Code Playgroud)
我怎样才能投value来paramType?value是string,paramType很可能只是一个基本的类型一样int,string或者可能float.如果没有可能的转换,我会很好地抛出异常.
c# ×1