What is the difference? I always use ByVal, but, I don’t really have a good idea of when should I and when not…
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.
If you pass in a reference, when you modify the value in the method, the variable in the call site will also be modified.
If you pass value, it’s the same as if another variable is created at the method, so even if you modify it, the original variable (at the call site) won’t have its value changed.
So, indeed, you should usually pass variables as value. Only pass as reference if you have an explicit need to do so.