what is the difference between passing a value object by
reference and a reference object by value?

Answer Posted / ashish diwakar

Value Objects are the objects that contain the data as
objects such int, string, etc...
Reference Objects are the objects that contain the data as
reference such as StringBuilder,etc...

When a Value object is passed as reference the reference of
the object is passed to the method (which means that any
change made to variable will be reflected on the original
variable).
But when a Reference Object is passed by value Like :
StringBuilder sb =new StringBuilder();

sb.Append("hello");

Display(sb);

any change made on sb inside Display function will not
change value of sb.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to exclude a property from xml serialization?

646


Is c# or c++ better for games?

543


Can a constructor be private in c#?

562


What is a Jagged Array in C#?

635


What does void mean unity?

582






Which class comes after the SortedList class?

642


Can a static class have a constructor c#?

577


Why do we use struct in c#?

580


What is the syntax for calling an overloaded constructor within a constructor (this() and constructorname() does not compile)?

605


What is a type c#?

572


What is a jagged array?

587


Can list contain duplicates c#?

566


What is mvc in c#?

547


What are the generation of Garbage Collection in C# .NET ?

625


In how many ways you can overload a method?

660