I have a general question about object declaration and initial instantiation. I regularly need to declare an object and then pass it byref / instantiate it in a Try Catch block. VS2005 always gives a warning:
Variable '<object name>' is used before it has been assigned a value. A null reference exception could result at runtime.
My question is do I ignore these warnings / can I explicitly switch them off / should I instead be declaring all objects used in this way like this:
VB Code:
Dim obj as Object = Nothing
This gets rid of the warning messages but is the correct way to do things and does it carry a performance penalty?
Thanks in advance for your comments.




Reply With Quote