马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
场景:方法 Update 有多个参数,其中有可为空的。我需要写个公共方法判断把不为空的参数拼接成一定格式。
例子:static void Main(string[] args)
{
Update("123");
}
public static string Update(string Parame1, string Parame2 = "")
{
SpliceParame();
return "";
}
public static string SpliceParame()
{
StackFrame frame = new StackFrame(1);
MethodBase method = frame.GetMethod(); //取得调用函数
foreach (var item in method.GetParameters())
{
string a = item.Name;
}
return "";
}
我已查到通这种方法能够取到 Update 方法的参数名称,但是值没有取到。求指导,如何取到传过来的值(Parame1 : 123, Parame2 : "")
|