简体   繁体   中英

How to set the default class when two classes have the same name

If I have two namespaces eg

using Code1.Dog;
using Code2.Cat;

and both namespaces have a class called "Legs", how I would i set the default one that is used, without writing a full name such as Code1.Dog.Legs?

In an ASP.NET controller I have a class called "User" but whenever I write it, it uses the default class in "System.Security.Principle". Would like to use my own class called "User" without using the full naming scheme eg "MyNamespace.User". How would I achieve this? There is no way to not include the original class "System.Security.Principle".

When you have classes with the same simple names, you must refer to them by their fully qualified class names.

That's the way even you can understand your code better too.

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