foreach(var filter in filters)
{
var filterType = typeof(Filters);
var method = filterType.GetMethod(filter);
if (method != null) value = (string)method.Invoke(null, new[] { value });
}
Is there a case-insensitive way to get a method?
Yes, use BindingFlags.IgnoreCase:
var method = filterType.GetMethod(filter,
BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.Instance);
Beware the possible ambiguity, you'd get an AmbiguousMatchException.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With