C#中的名字 [英] Names in C#

查看:84
本文介绍了C#中的名字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人都可以告诉我,一个类与它所在的

命名空间同名是否合法。我做了,并且编译器没有给出错误,但是它引起了一些非常奇怪的名字解决问题。

-

Dave

Can anyone tell me, is it legal for a class to have the same name as the
namespace it is in. I did it, and the compiler didn''t give an error, but it
caused some very odd name resolving problems.
--
Dave

推荐答案

嗨Dave,

它在你的回复中说完全合法:-)你有什么问题

看见,不应该有任何问题。


马克。


戴夫写道:
Hi Dave,
it is perfectly legal as you said in your reply :-) What issues are you
seeing, there should not be any.

Mark.

"Dave" wrote:
任何人都可以告诉我,一个类与它所在的名称空间同名是否合法。我做到了,编译器没有'不会给出错误,但它会导致一些非常奇怪的名称解决问题。
-
Dave
Can anyone tell me, is it legal for a class to have the same name as the
namespace it is in. I did it, and the compiler didn''t give an error, but it
caused some very odd name resolving problems.
--
Dave



Mark R. Dawson <马********* @ discussions.microsoft.com> skrev i en

meddelelse新闻:BB ********************************** @ microsof t.com ...
"Mark R. Dawson" <Ma*********@discussions.microsoft.com> skrev i en
meddelelse news:BB**********************************@microsof t.com...
任何人都可以告诉我,一个类与它所在的名称空间同名是否合法。我做到了,并且编译器没有给出错误,但是
它导致一些非常奇怪的名称解决问题。
Can anyone tell me, is it legal for a class to have the same name as the
namespace it is in. I did it, and the compiler didn''t give an error, but
it
caused some very odd name resolving problems.



它是完全合法的你在答复中说:-)你看到了什么问题,应该没有。



it is perfectly legal as you said in your reply :-) What issues are you
seeing, there should not be any.




例如,以下内容不会编译为class UseMyTest抱怨



''MyTest''表示''命名空间'',其中''类''是预期的。


使用系统;

名称空间MyTest

{

公共类MyTest

{

public MyTest()

{

}

}

}

使用系统;

使用MyTest;

nam espace AnotherNamespace

{

公共类UseMyTest

{

public UseMyTest()

{

MyTest myTest = new MyTest();

}

}

}



For example, the following will not compile as the class UseMyTest complains
that
''MyTest'' denotes a ''namespace'' where a ''class'' was expected.

using System;
namespace MyTest
{
public class MyTest
{
public MyTest()
{
}
}
}
using System;
using MyTest;
namespace AnotherNamespace
{
public class UseMyTest
{
public UseMyTest()
{
MyTest myTest = new MyTest();
}
}
}


您好,
类与
中的命名空间同名在框架中是否有这样的实例?

Roger


" Dave" <沓** @ discussions.microsoft.com>在消息中写道

新闻:B2 ********************************** @ microsof t.com ...任何人都可以告诉我,一个类与它所在的命名空间具有相同的名称是否合法。我做到了,并且编译器没有给出错误,但
它引起了一些非常奇怪的名称解决问题。
-
戴夫
class to have the same name as the namespace it is in In the Framework are there any instances of this?
Roger

"Dave" <Da**@discussions.microsoft.com> wrote in message
news:B2**********************************@microsof t.com... Can anyone tell me, is it legal for a class to have the same name as the
namespace it is in. I did it, and the compiler didn''t give an error, but it caused some very odd name resolving problems.
--
Dave



这篇关于C#中的名字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆