【发布时间】:2011-10-19 04:25:45
【问题描述】:
有没有什么晦涩难懂的方法可以将所有方法参数转换成一个对象[]?
在使用消息代理实现两个系统之间的集成时,我注意到代理公开的大多数方法都使用了很多参数。
我想要一种简单的方法来使用每个参数记录对代理的每次调用。比如:
[WebMethod]
public void CreateAccount(string arg1, int arg2, DateTime arg3, ... ) {
object[] args = GetMethodArgs();
string log = args.Aggregate("", (current, next) => string.Format("{0}{1};", current, next));
Logger.Log("Creating new Account: " + args);
// create account logic
}
我很好奇 C# 是否提供了模拟 GetMethodArgs();
【问题讨论】:
-
试试这个上一个问题:stackoverflow.com/questions/3288597/…