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

How to force my .net app to run as administrator on windows 7?

507


What is difference between web and window application?

401


What is the use of private constructor in c#?

501


In which situation(s), the use of "Delegate" is a good idea?

552


What is xml serialization in c#?

474






Can abstract class instantiated c#?

506


What is using keyword?

530


How does array sort work?

500


What is the use of parse in c#?

459


What is private class in c#?

482


What is the purpose of private constructor in c#?

553


What is difference between write and writeline in c#?

490


what is the purpose of using statement in c#

553


What is difference between C# and VB.NET?

516


What is gac? How to put assembly in gac?

557