简体   繁体   中英

Two packages have the same class name inside the same namespace. How to specifically use each class?

The Microsoft.Azure.Cosmos (v3.29.1.0) and Micosoft.Azure.Documents (v2.10.3.0) has the same class called UnixDateTimeConverter within the same namespace Microsoft.Azure.Documents . My project needs to use both packages, and I cannot rename both. How can I specifically use the class of Microsoft.Azure.Documents package? ( cause that of Micosoft.Azure.Documents has public access modifier which can be called anywhere)

Micosoft.Azure.Cosmos package

Micosoft.Azure.Documents package

the key is that they are not in same namespace and you can choose which one you would like to use in your using section of code for instance

using UnixDateTimeConverter = Microsoft.Azure.Cosmos.UnixDateTimeConverter;

this would instruct to use this implementation and not the older, but it is typically only necessary when you are using both namespaces to begin with, so just as often we can remove one of the using statements.

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