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 difference between constants and read-only?

663


What is difference between function and method in c#?

654


What is a property in c#?

677


What is the namespace for datatable in c#?

743


List the fundamental oop concepts?

702


What is null character in string?

770


Is null empty or whitespace c#?

734


i want the csharp questions&answeres

1720


Ho we can see assembly information?

734


What is literal control

782


What is private virtual in C#?

793


What are the various components in crystal reports?

730


What is the signature of a method?

701


What do you mean by for each loop?

692


List down the reason behind the usage of c# language.

926