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

Explain types of comment in c# with examples

688


What is the difference between a private assembly and a shared assembly?

775


What is orm in c#?

681


How do generics work in c#?

675


What is difference between ienumerable and list in c#?

642


How do I do implement a trace and assert?

773


is it possible to access a remote web service Without UDDI?

773


How many types of delegates are there in c#?

668


Explain About Assembly in .NET, types of assemblies, their difference, How to register into GAC. How to generate the strong names & its use.

805


How long does it take to get a loop recorder put in?

654


What are generics in c#.net?

792


Can c# inherit multiple classes?

731


Explain the role of Garbage collector and its generations?

715


What is parseexact c#?

689


Can we inherit a private class in c#?

648