I can create a new object like this:
Dim sqlconn As New SqlClient.SqlConnection(cs)
or like this:
Dim sqlconn = New SqlClient.SqlConnection(cs)
What’s the difference? Since both worked fine for me!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The first one is the short form of:
The second one depends on what version of VB you are using. In VB 7 and VB 8 it is the same as:
In VB 9 type inference was introduced, so the compiler will infer the type from the assignment and produce the same code as the first one.
The type inference requires that the option
Option Inferis set toon. This is the default setting, but it might be off if you migrate a project from an older version.