如何动态传递字符串方法以在运行时应用于字符串。前任。
Private String Formatting(String Data, String Format)
当我们通过String S1 = "S1111tring Manipulation"并且format = Remove(1,4)- 在幕后它会S1.Remove(1,4)导致“字符串操作”
或者如果我们经过String  S1 = "S1111tring Manipulation"并且format = ToLower()在幕后它会S1.ToLower()导致"s1111tring manipulation"
我应该能够传递任何有效的方法,如,PadLeft(25,'0')等...PadRightReplace
我会很感激一个完整的例子
这是我尝试过的,但它不起作用
using System.Reflection;
string MainString = "S1111tring Manipulation";
string strFormat = "Remove(1, 4)";
string result = DoFormat(MainString, strFormat);
private string DoFormat(string data, string format)
        {
            MethodInfo mi = typeof(string).GetMethod(format, new Type[0]);
            if (null == mi)
                throw new Exception(String.Format("Could not find method with name '{0}'", format));
            return mi.Invoke(data, null).ToString();
        } 
引发错误(找不到名称为“Remove(1, 4)”的方法) - 所以我不确定如何继续