[英]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?并且两个命名空间都有一个名为“Legs”的类,我将如何设置使用的默认类,而无需编写诸如 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".在 ASP.NET 控制器中,我有一个名为“User”的类,但是每当我编写它时,它都会使用“System.Security.Principle”中的默认类。 Would like to use my own class called "User" without using the full naming scheme eg "MyNamespace.User".
想使用我自己的名为“User”的类而不使用完整的命名方案,例如“MyNamespace.User”。 How would I achieve this?
我将如何实现这一目标? There is no way to not include the original class "System.Security.Principle".
没有办法不包括原始类“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.这也是您可以更好地理解代码的方式。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.