简体   繁体   中英

Namespace conflicts

Ive got a project that uses the Google .NET API.

It has a root namespace of 'Google' (unsuprisingly).

Ive just created a class with the following namespace

namespace Foo.Google{    
class Bar{ }
}

Obviously this is now going to 'conflict' as Google is ambiguous (precedence is actually given to Foo.Google ).

Other than just renaming Foo.Google to Foo.Goog , are then any other cleverer approaches?

尝试global::Google.Whatever

您可以使用别名导入Google .NET API(检查参考属性)。

No, there are no cleverer approaches. Avoiding namespaces conflicts by not using the same namespaces of the third party code which you use is the way to go.

(如果我对问题的理解正确)您不能执行以下操作:

using GoogleApi = Google;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM