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

Answers were Sorted based on User's Feedback



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

Answer / c

I am sorry ...above is not correct....actually to pass
reference type as value we need to use clonable/ copy
constructor ...otherwise in C# it is not possible to pass
object as value

Is This Answer Correct ?    2 Yes 0 No

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

Answer / ashish diwakar

..........For above example..............

Well I skip to add .ToString in my above answer.

We can not pass Reference type objects directly to a method.
So to pass value of sb variable we need to use following
code:

Display(sb.ToString());


..........For above example..............

Is This Answer Correct ?    1 Yes 0 No

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

Answer / 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

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

Answer / c

When you pass object by reference to any method, you are
passing reference (base pointer) to method. Any changes
done on this object will get reflected in object in caller.

When you pass any object by value, you are passing copy of
the object and not the reference.

Is This Answer Correct ?    1 Yes 2 No

Post New Answer

More C Sharp Interview Questions

What is a derived class in c#?

0 Answers  


Hello Friends..am Mohammed riyash..final year BCA in Jamal Mohamed College 2009. Trichy. My doubt is while connecting SQL2005 Built in Database withing the Visual Studio 2005 Framework.. I am getting the error.. That " An Error occurred and it may be due to , under the default settings of the Server, the connection cannot be established.." But the code works in MS Access for me.. Both in VB.Net and C#.Net am getting the same error.. Any genius please Message me to 9994558822 or mail me.. riyash.ips@gmail.com

3 Answers  


What are the three types of predicates?

0 Answers  


Define delegate in c#?

0 Answers  


what is work of continue statement in C#?

3 Answers  






What is the difference between class and namespace?

0 Answers  


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

0 Answers  


What are the types of inheritance in c#?

0 Answers  


What is inline function in c#?

0 Answers  


What is parallel programming in c#?

0 Answers  


What is datagrid c#?

0 Answers  


List some Advantages of switch-case over if else?

0 Answers  


Categories