Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
VB.Net Question
Message
From
12/05/2009 00:33:47
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Miscellaneous
Thread ID:
01399325
Message ID:
01399329
Views:
61
>What is the difference between these two lines of code?
>
>
>Dim MyConnection As New SqlConnection()
>Dim RetVal As SqlConnection = New SqlConnection()
>
Additionnally to what Mike said, I like the second declaration as it shows the type and the value/object assigned to it.

But, sometimes, we cannot do that. What I do in this case, is to assign to Nothing. Then, in the code later down below, I can assign the value or the object to it. I always have all my declarations at the top with a pre-defined value assigned to it. This makes it more clear to read and understand its meaning.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Reply
Map
View

Click here to load this message in the networking platform