Nothing vs String.Empty
Posted on 2008-10-04
Hi, I'm using VB 2005, WinForms. I have a question about initializing variables and setting their value from a best practices point of view.
Let say I have a String variable called "strMyString" and I want to initialize its value to "No Value".
What is the best way to accomplish this, so that I can avoid problems in my code with DBNulls later at runtime.
Which of the following would be better -- or does it make a difference.
Dim strMyString as String = Nothing
Dim strMyString as String = String.Empty
Dim strMyString as String = ""
Is there a better way?
Thanks for your help,