Difference between ByVal and ByRef?

Answer Posted / priya

If you want to pass the value of the variable, use the
ByVal syntax. By passing the value of the variable instead
of a reference to the variable, any changes to the variable
made by code in the subroutine or function will not be
passed back to the main code. This is the default passing
mechanism when you don’t decorate the parameters by using
ByVal or ByRef.

If you want to change the value of the variable in the
subroutine or function and pass the revised value back to
the main code, use the ByRef syntax. This passes the
reference to the variable and allows its value to be
changed and passed back to the main code.

Is This Answer Correct ?    2 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the use of generics in c#?

616


What floating point types is supported in C#?

749


What is the signature of a method?

654


Why do we use overloading in c#?

657


What is dynamic dispatch?

700






What does question mark mean in c#?

763


Why do we use classes?

648


Describe the process of “exception handling implementation” in c#?

686


Which attribute is used in order that the method can be used as webservice?

701


What is uint64?

692


What are the characteristics of c#?

652


How to open a new form on button click in Windows forms?

702


Differentiate between response.expires and response.expiresabsolute?

728


What is a method c#?

649


Is c# code is unmanaged or managed code?

714