【发布时间】:2013-01-29 18:00:02
【问题描述】:
我有一个被另一部分代码调用的函数,其签名为:
public override bool DoSomething(Foo f, out string failed)
{
failed = "I failed";
_anotherClassMethodExpectingString.SetString(failed);
}
所以我的问题是 - 如果我需要向另一个类方法发送我的调用者在其“out”参数中期望的相同字符串,我可以只发送相同的变量,而不会对我的调用者产生任何影响吗? “out”参数让我有点困惑.. 我应该改用这样的东西吗:
public override bool DoSomething(Foo f, out string failed)
{
string localStr = "I failed";
failed = localStr;
_anotherClassMethodExpectingString.SetString(localStr);
}
【问题讨论】: