.net – Different ways to declare VB variables

vb.net

I'm new to VB.NET programming. What I'm confused about is the different ways one can declare a variable. Would someone please explain the difference between the two declarations below?

Dim sqlcommand As MySqlDataAdapter = New MySqlDataAdapter(sql, db)

And:

Dim anotherSqlcommand As New MySqlDataAdapter(sql, db)

Best Answer

There is no difference.

Sometimes you want to use the first method though if you want to take advantage of interfaces...

Dim myList As IList(Of Something) = New List(Of Something)

Instead of being restricted to List(Of Something)

Dim myList As New List(Of Something)
Related Topic