::运算符和“全局”运算符。 [英] The :: operator, and "global"
本文介绍了::运算符和“全局”运算符。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在最近的帖子中看到::运算符用于到达全局命名空间,
global :: MyNamespace
之前我没有见过这个,所以在MSDN中查找了它,它解释了它很好。我的问题是,做全球吗?和::总是一起去?这些运营商还有其他用途吗?比如一对吗?
TIA,
Javaman
I saw in a recent post the :: operator used to reach the global namespace, as
in
global::MyNamespace
I hadn''t seen this before, so looked it up in MSDN, which explained it
nicely. My question is, do "global" and "::" always go together? Is there any
other use for these operators, than as a pair?
TIA,
Javaman
推荐答案
Javaman,
AFAIK,没有全球的c#2.0中的关键字。你只使用运算符'''''
来表示编译器从''outest'范围开始搜索:
命名空间A {
命名空间系统{
class X {
public void消息(字符串s)
{
:: System.Windows.Forms.MessageBox.Show(s); //'''''需要这里
}
}
}
}
问候 - Octavio
" Javaman59" < JA ******* @ discussions.microsoft.com> escribióenel mensaje
news:76 ********************************** @ microsof t.com ...
Javaman,
AFAIK, there''s no "global" keyword in c# 2.0. You only use the operator ''::''
to indicate the compiler to start the search from the ''outest'' scope:
namespace A {
namespace System {
class X {
public void Message(string s)
{
::System.Windows.Forms.MessageBox.Show(s); // ''::'' needed here
}
}
}
}
Regards - Octavio
"Javaman59" <Ja*******@discussions.microsoft.com> escribió en el mensaje
news:76**********************************@microsof t.com...
我在最近的帖子中看到::运算符用于到达全局命名空间,
global :: MyNamespace
之前我没有见过这个,所以在MSDN中查找了它,很好地解释了它。我的问题是,做全球吗?和::总是一起去?对于这些操作员来说,还有其他用途吗?比如一对吗?
TIA,
Javaman
I saw in a recent post the :: operator used to reach the global namespace,
as
in
global::MyNamespace
I hadn''t seen this before, so looked it up in MSDN, which explained it
nicely. My question is, do "global" and "::" always go together? Is there
any
other use for these operators, than as a pair?
TIA,
Javaman
您应该在发布之前检查。您的代码将无法编译 - 这就是C ++构造。 C#v2中有一个全局关键字,它总是与::一起表示该类型的全局范围。
global :: System.Windows.Forms.MessageBox.Show(" ; foo");
问候
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Javaman,
AFAIK,没有全球的c#2.0中的关键字。你只使用运算符'''''
来表示编译器从''outest'范围开始搜索:
命名空间A {
命名空间系统{
class X {
public void消息(字符串s)
{
:: System.Windows.Forms.MessageBox.Show(s); //'''''需要这里
}
}
}
}
问候 - Octavio
" Javaman59" < JA ******* @ discussions.microsoft.com> escribi? en el mensaje
news:76 ********************************** @ microsof t.com ...
You should probably check before you post. Your code will not compile - thats a C++ construct. There is a global keyword in C# v2 and it always goes together with :: to indicate global scope of the type.
global::System.Windows.Forms.MessageBox.Show("foo" );
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Javaman,
AFAIK, there''s no "global" keyword in c# 2.0. You only use the operator ''::''
to indicate the compiler to start the search from the ''outest'' scope:
namespace A {
namespace System {
class X {
public void Message(string s)
{
::System.Windows.Forms.MessageBox.Show(s); // ''::'' needed here
}
}
}
}
Regards - Octavio
"Javaman59" <Ja*******@discussions.microsoft.com> escribi? en el mensaje
news:76**********************************@microsof t.com...
我在最近的帖子中看到::运算符用于到达全局命名空间,
在
全局:: MyNamespace
之前我没有见过这个,所以在MSDN中查找了它,很好地解释了它。我的问题是,做全球吗?和::总是一起去?对于这些操作员来说,还有其他用途吗?比如一对吗?
TIA,
Javaman
I saw in a recent post the :: operator used to reach the global namespace,
as
in
global::MyNamespace
I hadn''t seen this before, so looked it up in MSDN, which explained it
nicely. My question is, do "global" and "::" always go together? Is there
any
other use for these operators, than as a pair?
TIA,
Javaman
[microsoft.public.dotnet.languages.csharp]
[microsoft.public.dotnet.languages.csharp]
Richard,
谢谢你校正。
实际上我做了那个检查,指的是我一直认为的MSDN杂志
优秀:
http://msdn.microsoft.com/msdnmag/is...0/ default.aspx
也许文章有点陈旧,规格从那时起发生了变化?
问候 - Octavio
" Richard Blewett [DevelopMentor]" < RI ****** @ NOSPAMdevelop.com> escribióen
el mensaje新闻:%2 **************** @ TK2MSFTNGP09.phx.gbl ...
Richard,
Thanks for your correction.
Actually I did that check, referring to a MSDN Magazine I always considered
excellent:
http://msdn.microsoft.com/msdnmag/is...0/default.aspx
Maybe the article is little bit old and specs have changed since then?
Regards - Octavio
"Richard Blewett [DevelopMentor]" <ri******@NOSPAMdevelop.com> escribió en
el mensaje news:%2****************@TK2MSFTNGP09.phx.gbl...
你应该在你发布之前检查。您的代码将无法编译 - 这就是C ++构造。 C#v2中有一个全局关键字,它总是和::一起表示该类型的全局范围。
global :: System.Windows.Forms.MessageBox.Show(" ; foo");
问候
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Javaman,
AFAIK,没有 ;全球" c#2.0中的关键字。您只能使用运算符
''::''
来指示编译器从''outest'范围开始搜索:
命名空间A {
namespace System {
class X {
public void Message(string s)
:: System.Windows.Forms.MessageBox.Show(s); //''::''需要在这里
}
}
}
问候 - Octavio
" ; Javaman59" < JA ******* @ discussions.microsoft.com> escribi? en el mensaje
新闻:76 ********************************** @ microsof t.com。 ..
You should probably check before you post. Your code will not compile -
thats a C++ construct. There is a global keyword in C# v2 and it always
goes together with :: to indicate global scope of the type.
global::System.Windows.Forms.MessageBox.Show("foo" );
Regards
Richard Blewett - DevelopMentor
http://www.dotnetconsult.co.uk/weblog
http://www.dotnetconsult.co.uk
Javaman,
AFAIK, there''s no "global" keyword in c# 2.0. You only use the operator
''::''
to indicate the compiler to start the search from the ''outest'' scope:
namespace A {
namespace System {
class X {
public void Message(string s)
{
::System.Windows.Forms.MessageBox.Show(s); // ''::'' needed here
}
}
}
}
Regards - Octavio
"Javaman59" <Ja*******@discussions.microsoft.com> escribi? en el mensaje
news:76**********************************@microsof t.com...
我在最近的帖子中看到::运算符用于到达全局
命名空间,
全局:: MyNamespace
之前我没有见过这个,所以在MSDN中查找了它,很好地解释了它。我的问题是,做全球吗?和::总是一起去?对于这些运营商来说还有其他用途,而不是作为一对吗?
TIA,
Javaman
I saw in a recent post the :: operator used to reach the global
namespace,
as
in
global::MyNamespace
I hadn''t seen this before, so looked it up in MSDN, which explained it
nicely. My question is, do "global" and "::" always go together? Is
there
any
other use for these operators, than as a pair?
TIA,
Javaman
[microsoft.public.dotnet.languages.csharp]
[microsoft.public.dotnet.languages.csharp]
这篇关于::运算符和“全局”运算符。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文