名称空间和类名称冲突

我有一个叫做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

任何人都可以帮助我理解为什么会发生这种情况,如果可能的话,我怎样才能做到我想要的?

Interesting Posts