Difference between ByVal and ByRef?

Answer Posted / ashwini

When arguments are passed to a method ByVal i.e. By Value
then the original value of a variable is not passed but its
copy is created and that copy is passed. So whatever
changes are made, they will affect the copy but not the
original value of a variable.
When arguments are passed ByRef i.e. By Reference
then the argument's memory location is passed to a method.
So changes made to that argument's value will actually
affect the original value.

Is This Answer Correct ?    31 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why can't we use a static class instead of singleton?

455


Is python easier than c#?

499


What is c# most used for?

568


What is the difference between add and addrange in c#?

512


what is a destructor?

606






Why do we need interface in c#?

506


Why use “using” in c#?

529


What is a string in c#?

483


What is int32 in c#?

506


What is the use of properties window?

504


What are sessions in c#?

497


What is the difference between public, static, and void?

483


What is parameters in c#?

503


What is the c# equivalent of c++ catch (...), Which was a catch-all statement for any possible exception?

502


How many digits is a 32 bit number?

481