您更喜欢哪种声明/分配方法? [英] Which declaration/assignment method do you prefer?
问题描述
当声明一个变量并在一行中为它赋值时,你用哪种方式
:
Dim x As New SomeClass( < parameters>)
或
Dim x As SomeClass = New SomeClass(< parameters>)
两者之间是否存在功能差异?
When declaring a variable and assigning a value to it in one line, which way
do you do it:
Dim x As New SomeClass(<parameters>)
or
Dim x As SomeClass = New SomeClass(<parameters>)
Are there any functional differences between the two?
推荐答案
我更喜欢第二种。我发现我的自己有时不得不使用Try Catch块来改变我的代码
。第一种方法使得这些更改更容易。没有区别(与VB 6不同)。
Dim x As SomeClass
尝试
x = New SomeClass (< paramters>)
Catch
最后
x.DoSomething
结束尝试
格雷格
杰夫约翰逊[MVP:VB]" <我*** @ enough.spam>在留言中写道
news:%2 **************** @ TK2MSFTNGP12.phx.gbl ...
I prefer the second. I find my self sometimes having to change my code when
using a Try Catch block. The first method makes making those changes
easier. There is no difference (unlike VB 6).
Dim x As SomeClass
Try
x = New SomeClass(<paramters>)
Catch
Finally
x.DoSomething
End Try
Greg
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
声明时一个变量并在一行中为它赋值,你用
的方式:
Dim x As New SomeClass(< parameters>)
或者
Dim x As SomeClass = New SomeClass(< parameters>)
这两者之间是否有任何功能差异?
When declaring a variable and assigning a value to it in one line, which way do you do it:
Dim x As New SomeClass(<parameters>)
or
Dim x As SomeClass = New SomeClass(<parameters>)
Are there any functional differences between the two?
>
它早期绑定或晚期绑定问题!
我更喜欢早期绑定!
Bismark
杰夫约翰逊[MVP:VB]" <我*** @ enough.spam>一个écritdansle message de
新闻:%2 **************** @ TK2MSFTNGP12.phx.gbl ...
It Early Binding or Late Binding problem !
I prefer Early Binding !
Bismark
"Jeff Johnson [MVP: VB]" <i.***@enough.spam> a écrit dans le message de
news:%2****************@TK2MSFTNGP12.phx.gbl...
当声明一个变量并在一行中为它赋值时,你会采用
的方式:
Dim x As New SomeClass(< parameters>)
<暗淡x As SomeClass = New SomeClass(< parameters>)
这两者之间是否有任何功能差异?
When declaring a variable and assigning a value to it in one line, which way do you do it:
Dim x As New SomeClass(<parameters>)
or
Dim x As SomeClass = New SomeClass(<parameters>)
Are there any functional differences between the two?
Jeff,
Jeff,
当声明变量并在一行中为其赋值时,以哪种方式执行你这样做:
Dim x As New SomeClass(< parameters>)
Dim x As SomeClass = New SomeClass(<参数>)
我更喜欢#1。减少打字是一件好事。
这两者之间是否有任何功能差异?
When declaring a variable and assigning a value to it in one line, which way
do you do it:
Dim x As New SomeClass(<parameters>)
or
Dim x As SomeClass = New SomeClass(<parameters>)
I prefer #1. Less typing is a good thing.
Are there any functional differences between the two?
否。它肯定没有与早期/晚期绑定有关
有人建议。
Mattias
-
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
请回复到新闻组。
No. It certainly doesn''t have anything to do with early/late binding
as someone suggested.
Mattias
--
Mattias Sj?gren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
这篇关于您更喜欢哪种声明/分配方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!