What’s the performance consequence using the ‘With’ keyword in vb.net instead of using reusing the instance name over and over?
What’s the performance consequence using the ‘With’ keyword in vb.net instead of using reusing
Share
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.
Assuming that you’re comparing it to a local variable reference, there is no difference whatsoever; both will emit the exact same IL. (At least in Release mode)
However, if you’re comparing it to repeated invocations of a property or indexer,
Withwill be a little bit faster, and if you’re comparing it to repeated invocations of a method, it might be much faster. (TheWithkeyword will create a local variable and assign it to the object that youWith‘d, so the method will only be called once instead of on every line)