如何理解命名空间的使用...... [英] How to understand the use of namespaces ...

查看:51
本文介绍了如何理解命名空间的使用......的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用2.0与母版页和一个GlobalBaseClass用于内容页面。


我理解简单部分 - 命名空间的层次结构

命名惯例 - 但是2.0 IDE没有为

开发人员写一个签名,并且在开始开发2.0应用程序之后我认为我应该通过代码和开始标记类并使用

命名空间。即使在基类中使用

第一级命名空间,例如以及其他类

,例如部分类,我仍然会收到以下丢失错误我写的和实用程序类。


//错误

无法找到类型或命名空间名称''GlobalBaseClass'(你是

缺少using指令或汇编引用?)


所以如果我尝试这个第一级签名...


命名空间CompanyName

{

....

}


''缺失''发生错误。


我已经有至少二十几个部分类的实例和四个

我自己的实用程序类。是否每个类都需要

中的第一级CompanyName命名空间?这些问题在我的

混乱的头脑中仍然是模糊不清的。


有人可以解释或提供一个博客或教程的URL,真正得到

编译器想要声明名称空间的位置和时间?


<%= Clinton Gallagher

解决方案
" clintonG" < CS ********* @ REMOVETHISTEXTmetromilwaukee.com>写在消息

新闻:英国************** @ TK2MSFTNGP15.phx.gbl ...

使用2.0与母版页内容页面的GlobalBaseClass。

我理解简单部分 - 命名空间的层次结构
命名约定 - 但是2.0 IDE没有为命名空间标记类。即使在基类中使用
第一级命名空间,以及其他类,例如我编写的部分类和实用程序类,我仍然会收到以下丢失错误。

//错误
无法找到类型或命名空间名称''GlobalBaseClass'(你是否缺少using指令或程序集引用?)

所以如果我尝试这个第一级签名......

命名空间CompanyName
{
...
}

发生''missing''错误。

我已经有至少二十几个部分类的实例和四个我自己的实用程序类。每个类中是否需要第一级CompanyName命名空间?在我的混乱思想中,这些问题仍然是模糊不清的。

有人可以解释或提供一个博客或教程的URL,这些博客或教程真正进入了何时何地编译器是否要声明名称空间?

<%= Clinton Gallagher




看起来编译器无法解析类型GlobalBaseClass。 />
它告诉你究竟是什么问题:要么你没有参考

到包含GlobalBaseClass的程序集,要么就是你的

命名空间,你不要使用,或者两者都使用。


问候


Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk


嗨克林顿,


每个类将使用另一个类来自另一个

的类,而不是它自己的命名空间这个名称空间必须添加



例如


##使用MyNamespace1开始

;

使用MyNamespace2;


命名空间MyNamespace3

{

//这里你可以使用命名空间中的类

// MyNamespace1,MyNamespace2

}

## end


请注意,如果您必须使用的命名空间是单独的

dll,你必须将它们添加到你的项目引用中。

使用mean只使用不引用dll'的。


希望有所帮助; )


干杯

Lars Behrmann


_________________

没有什么是不可能的。 UML是解决所有问题的关键。

AODL - 让您的.net应用程序OpenOffice准备就绪
http://aodl.sourceforge.net/

clintonG schrieb:

使用2.0使用Master Pages和GlobalBaseClass作为内容页面。

我理解简单部分 - 命名空间的层次结构
命名约定 - 但2.0 IDE不会为
开发人员在开始开发2.0应用程序之后,我认为我应该通过代码并开始使用
命名空间标记类。即使在基类中使用
第一级命名空间以及其他类(例如我编写的部分类和实用程序类),我仍然会收到以下丢失错误。

//错误
无法找到类型或命名空间名称''GlobalBaseClass'(你是否缺少using指令或程序集引用?)

所以如果我尝试这个第一级签名......

命名空间CompanyName
{
...
}

发生''missing''错误。

我已经有至少二十几个部分类的实例和四个我自己的实用程序类。
每个类都需要第一级CompanyName命名空间吗?这些问题在我糊涂的头脑中仍然是模糊不清的。

有人可以解释或提供一个博客或教程的URL,这些博客或教程真正进入了何时何地编译器是否要声明名称空间?

<%= Clinton Gallagher




我认为你应该先了解一下在.NET中没有这样的东西作为

命名空间

虽然类可能包含点,而Visual Studio和C#
$ b等语言$ b使用这些点来创建类组实际上只有

程序集包含类和对实际工作的程序集的引用

with。


Happy Coding

- Michael S


ps。

我遗漏了几个,和。希望有些人会在上面大声读出上述内容时晕倒。


Using 2.0 with Master Pages and a GlobalBaseClass for the content pages.

I understand the easy part -- the hierarchical structure of a namespace
naming convention -- but the 2.0 IDE does not write a signature for the
developer and after getting a good start developing a 2.0 application I
thought I should go through the code and start marking classes and with
namespaces. I keep getting the following ''missing'' error even when using a
first level namespace in the base class for example as well as other classes
such as the partial class and utility classes I have written.

// Error
The type or namespace name ''GlobalBaseClass'' could not be found (are you
missing a using directive or an assembly reference?)

So if I try this first level signature...

namespace CompanyName
{
....
}

The ''missing'' error occurs.

I have at least two dozen instance of partial classes already and four of
my own utility classes. Is the first level CompanyName namespace required in
each and every class? These are the sorts of issues that remain murky in my
muddled mind.

Can somebody explain or provide a URL to a blog or tutorial that really gets
into where and when the compiler wants namespaces declared?

<%= Clinton Gallagher

解决方案

"clintonG" <cs*********@REMOVETHISTEXTmetromilwaukee.com> wrote in message
news:uK**************@TK2MSFTNGP15.phx.gbl...

Using 2.0 with Master Pages and a GlobalBaseClass for the content pages.

I understand the easy part -- the hierarchical structure of a namespace
naming convention -- but the 2.0 IDE does not write a signature for the
developer and after getting a good start developing a 2.0 application I
thought I should go through the code and start marking classes and with
namespaces. I keep getting the following ''missing'' error even when using a
first level namespace in the base class for example as well as other
classes such as the partial class and utility classes I have written.

// Error
The type or namespace name ''GlobalBaseClass'' could not be found (are you
missing a using directive or an assembly reference?)

So if I try this first level signature...

namespace CompanyName
{
...
}

The ''missing'' error occurs.

I have at least two dozen instance of partial classes already and four of
my own utility classes. Is the first level CompanyName namespace required
in each and every class? These are the sorts of issues that remain murky
in my muddled mind.

Can somebody explain or provide a URL to a blog or tutorial that really
gets into where and when the compiler wants namespaces declared?

<%= Clinton Gallagher



It appears that the type GlobalBaseClass is not resolvable by the compiler.
Its telling you exactly what the issue is: either you don''t have a reference
to the assembly that contains GlobalBaseClass or you do but its in a
namespace that you don;t ave a using statement for - or maybe both.

Regards

Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk


Hi Clinton,

each class which will use a class from another
than it''s own namespace this namespace have to
be add.

e.g.

##start
using MyNamespace1;
using MyNamespace2;

namespace MyNamespace3
{
//here you can use classes from the namespaces
//MyNamespace1, MyNamespace2
}
##end

Please notice, that if the namespace you have to use is in an seperate
dll, you have to add them to your project references.
Using mean only using not reference the dll''s.

Hope that helps ;)

Cheers
Lars Behrmann

_________________
Nothing is impossible. UML is the key for all your problems.
AODL - Make your .net apps OpenOffice ready
http://aodl.sourceforge.net/

clintonG schrieb:

Using 2.0 with Master Pages and a GlobalBaseClass for the content pages.

I understand the easy part -- the hierarchical structure of a namespace
naming convention -- but the 2.0 IDE does not write a signature for the
developer and after getting a good start developing a 2.0 application I
thought I should go through the code and start marking classes and with
namespaces. I keep getting the following ''missing'' error even when using a
first level namespace in the base class for example as well as other classes
such as the partial class and utility classes I have written.

// Error
The type or namespace name ''GlobalBaseClass'' could not be found (are you
missing a using directive or an assembly reference?)

So if I try this first level signature...

namespace CompanyName
{
...
}

The ''missing'' error occurs.

I have at least two dozen instance of partial classes already and four of
my own utility classes. Is the first level CompanyName namespace required in
each and every class? These are the sorts of issues that remain murky in my
muddled mind.

Can somebody explain or provide a URL to a blog or tutorial that really gets
into where and when the compiler wants namespaces declared?

<%= Clinton Gallagher




I think you should start by understanding that there is no such thing as a
namespace in .NET

While classes may contain dots and while Visual Studio and languages like C#
uses these dots to create groups of classes there are actually only
assemblies containing classes and references to assemblies you actually work
with.

Happy Coding
- Michael S

ps.
I left out a couple of , and . in hope that some people would faint while
reading the above out loud.


这篇关于如何理解命名空间的使用......的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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