简体   繁体   中英

#define to resolve namespace clashes

I have several WCF services that share classes but because of the way WCF works, these classes are all seen as new and different classes.

Question: Is there a way to use C#'s #define to nicely resolve the clashes in a more readable way?

Can I do something like

#define Dog global::My_Project.DogServiceReference.Dog

So that I can then do

List <Dog> dogs = ...

instead of

List<global::My_Project.DogServiceReference.Dog>

@Chris Dunaway wrote:

Will a using alias work for this" using GlobalDog = global::My_Project.DogServiceReference.Dog and then use List<GlobalDog> dogs = ...
I haven't tried this.

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