我有一个名为的类Functions,它位于命名空间中,比如说SomeNameSpace. 在Functions课堂上,我有一个名为的函数GetCurrentValue,我用它来创建一个要在公式栏中显示的 excel 公式。我想从公式方程开始,=SomeNameSpace.Functions.GetCurrentValue但是当我尝试这个时
using System.IO;
using System;
namespace SomeNameSpace{
public class Functions{
public object GetCurrentValue (arg1, arg2...){
//GetCurrentValue method implementation
}
}
}
using System.IO;
using System;
using SomeNameSpace;
namespace AnotherNamespace{
public static bool SetFormula (string newFormula){ //newFormula value is "GetCurrentValue"
string sTemp = "=SomeNameSpace.Functions.";
string Formula = sTemp + newFormula;
return true;
}
Formula只设置为=GetCurrentValue. 我还意识到,当我更改sTemp为 以外的字符串时=SomeNameSpace.Functions.,例如,=SomeSpace.Functions.它可以完美运行,就像Formula设置为=SomeSpace.Functions.GetCurrentValue.
谁能帮我理解为什么会发生这种情况,如果可能的话,我怎样才能做我想做的事?