Is there a good reason (advantage) for programming this style
XmlDocument doc = null;
doc = xmlDocuments[3];
vs
XmlDocument doc = xmlDocuments[3];
I have seen it many times but to me it just seem overly verbose
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.
No – it’s generally considered best practice to declare a variable as late as you can, preferably setting it at the point of declaration. The only time when I don’t do that is when I have to set a variable conditionally, or it’s set in a more restrictive scope:
Reasons for declaring at the point of first use where possible: