名称空间和类名称冲突
我有一个叫做Functions
的类,在命名空间中,让我们来说SomeNameSpace
。 在Functions
类中,我有一个名为GetCurrentValue
的函数,我正在使用该函数创build一个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.
以外的string=SomeNameSpace.Functions.
例如, =SomeSpace.Functions.
,它工作完美,因为在Formula
获取设置=SomeSpace.Functions.GetCurrentValue
。
任何人都可以帮助我理解为什么会发生这种情况,如果可能的话,我怎样才能做到我想要的?