Which code snippet is better? and How? ['Better' on the basis of, readability, debug, code standards etc...,]
Dim Name As String = Employee.Name
or
Dim Name As String
Name = Employee.Name
Which code snippet is better? and How? ['Better' on the basis of, readability, debug, code standards etc...,]
Dim Name As String = Employee.Name
or
Dim Name As String
Name = Employee.Name
Well as they are both equivalent and both very simple I would expect the compiler to reduce them to the same thing so neither is really better.
Personally I feel the second has its advantages in that you can create several variables of one type in one line of code and then initialise them one after the other which for readable code is my preference. But if you only have one variable to initialise then the first is nice and concise as well.
Combining declaration and assignement is generally thought to be the best approach (your first example)
As long as there is no null / empty or content checking between declaration and assignment, I prefer option number 1. Easier to read and less clutter.