I would suspect that both 1 and 2 would run slightly faster, as they are
shortcuts, and are a single instruction, whereas the third is 2
instructions. However, the compiler might just be smart enough to compile
all 3 to the same IL code.
As to the factors involved, make sure you understand what each is doing. I
have seen green developers use Number 1 or Number 2 when there was no need
to instantiate the object (the object was instantiated later as a result of
some other instruction), which is a waste of processor.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.
"Mark Kamoski" <mk******@yahoo.com> wrote in message
news:OH**************@tk2msftngp13.phx.gbl...
Hi Everyone--
Please help.
What (really) is the difference between these 3 code snippets?.
'1
Dim objData1 As New DataSet()
'2
Dim objdata2 As DataSet = New DataSet()
'3
Dim objdata3 As DataSet
objdata3 = New DataSet()
Which is fastest?
Is there ANY difference between them?
Which do you prefer?
Which do you suggest?
What are the factors involved?
Please advise.
Thank you very much.
--Mark