为什么ToString不需要() [英] Why doesn't ToString require ()
问题描述
在VS 2008中,为什么ToString不需要()。
如果我有Option Strict On,为什么我可以同时执行这两项操作:
selectedIndex.ToString()
selectedIndex.ToString
或
sQuery = temp.ToUpper()。IndexOf(" friend")
sQuery = temp.ToUpper.IndexOf(" friend")
Aren''是否需要括号?
我可以理解,如果Option Strict Off,但如果是Option Strict On,我会认为你需要C#中的括号。
谢谢,
Tom
为什么,
一个非顺序化程序的()在某种程度上是rudimentair,从
时间开始输入程序电传打字机。有很多
在C#中更复古然后在VB中。
Cor
" tshad" < tf*@dslextreme.comschreef在bericht
新闻:OD ************** @ TK2MSFTNGP02.phx.gbl ...
在VS 2008中,为什么ToString不需要"()"。
如果我有Option Strict On我为什么可以同时做两件事:
selectedIndex.ToString()
selectedIndex.ToString
或
sQuery = temp.ToUpper()。IndexOf(" friend")
sQuery = temp.ToUpper.IndexOf(" friend")
不需要括号吗?
我可以理解,如果Option Strict Off,但是如果是Option Strict On,
我本来以为你需要用C#做括号。
谢谢,
Tom
" tshad" < tf*@dslextreme.comschrieb
在VS 2008中,为什么ToString不需要"()"
如果我有Option Strict On我为什么要这两个:
selectedIndex.ToString()
selectedIndex.ToString
< br $> b $ b或
sQuery = temp.ToUpper()。IndexOf(" friend")
sQuery = temp.ToUpper.IndexOf (朋友)
不需要括号吗?
要包含哪些参数?
我可以理解,如果Option Strict Off,但如果是选项
严格打开,我原以为你需要在C#中用括号作为
。
Option Strict是关于严格的类型处理,与此无关。
Armin
VB允许你在没有参数的情况下省略括号。
VB允许你为没有参数的属性调用添加括号。
VB有一个长期的传统,试图理解任何奇怪的怪癖
你想要培养。它对您很友好,但对程序员来说不是很友好。
谁必须阅读您的代码(为什么他们在这个属性上放置括号
来电? ,为什么他们使用这个静态方法调用的实例?等等。)
-
http://www.tangiblesoftwaresolutions.com
C ++到C#
C ++到VB
C ++到Java
VB& C#to Java
Java to VB& C#
即时C#:VB到C#
即时VB:C#到VB
即时C ++:VB,C#或Java到C ++ / CLI
" tshad"写道:
在VS 2008中,为什么ToString不需要"()"。
如果我有选项Strict On我为什么要这两个:
selectedIndex.ToString()
selectedIndex.ToString
或
sQuery = temp.ToUpper()。IndexOf(" friend")
sQuery = temp.ToUpper.IndexOf(" friend")
不需要括号吗?
我能理解,如果Option Strict Off,但如果是Option Strict On,我
会认为你需要像在C#中那样使用括号。
谢谢,
Tom
In VS 2008, why doesn''t ToString require "()".
If I have Option Strict On on why can I do both:
selectedIndex.ToString()
selectedIndex.ToString
or
sQuery = temp.ToUpper().IndexOf("friend")
sQuery = temp.ToUpper.IndexOf("friend")
Aren''t the parenthesis required?
I can understand that if Option Strict Off, but if it is Option Strict On, I
would have thought you would need the parenthesis as you do in C#.
Thanks,
Tom
Why,
The () for an not paramarized procedure is in a way rudimentair, from the
time that programs were entered with a teletype typewriter. There is a lot
more retro in C# then in VB.
Cor
"tshad" <tf*@dslextreme.comschreef in bericht
news:OD**************@TK2MSFTNGP02.phx.gbl...In VS 2008, why doesn''t ToString require "()".
If I have Option Strict On on why can I do both:
selectedIndex.ToString()
selectedIndex.ToString
or
sQuery = temp.ToUpper().IndexOf("friend")
sQuery = temp.ToUpper.IndexOf("friend")
Aren''t the parenthesis required?
I can understand that if Option Strict Off, but if it is Option Strict On,
I would have thought you would need the parenthesis as you do in C#.
Thanks,
Tom
"tshad" <tf*@dslextreme.comschriebIn VS 2008, why doesn''t ToString require "()".
If I have Option Strict On on why can I do both:
selectedIndex.ToString()
selectedIndex.ToString
or
sQuery = temp.ToUpper().IndexOf("friend")
sQuery = temp.ToUpper.IndexOf("friend")
Aren''t the parenthesis required?To enclose which parameters?
I can understand that if Option Strict Off, but if it is Option
Strict On, I would have thought you would need the parenthesis as
you do in C#.Option Strict is about strict type handling and has nothing to do with this.
Armin
VB allows you to omit parentheses in there are no arguments.
VB allows you to add parentheses to property calls that can''t have arguments.
VB has a long standing tradition of trying to make sense of any weird quirks
you feel like fostering. It''s friendly to you, but not to the programmers
who have to read your code ("why did they put parentheses on this property
call?", "why did they use an instance for this static method call?", etc.).
--
http://www.tangiblesoftwaresolutions.com
C++ to C#
C++ to VB
C++ to Java
VB & C# to Java
Java to VB & C#
Instant C#: VB to C#
Instant VB: C# to VB
Instant C++: VB, C#, or Java to C++/CLI
"tshad" wrote:
In VS 2008, why doesn''t ToString require "()".
If I have Option Strict On on why can I do both:
selectedIndex.ToString()
selectedIndex.ToString
or
sQuery = temp.ToUpper().IndexOf("friend")
sQuery = temp.ToUpper.IndexOf("friend")
Aren''t the parenthesis required?
I can understand that if Option Strict Off, but if it is Option Strict On, I
would have thought you would need the parenthesis as you do in C#.
Thanks,
Tom
这篇关于为什么ToString不需要()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!