Is string reference type / value type?

Answer Posted / djfox7200x

Strings are immutable.Hence they behave like a value type
when they are actually reference type;

eg. string objA="cat";
//cat is an immutable string in memory and objA points to
it.
string b=a; //reference is copied to b;

a="dog"; new immutable object created and a points to it;

//b is still cat since its refernce has not changed

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Distinguish between continue and break statement?

745


What are the types of serialization?

731


What does int32 mean in c#?

651


What are the ways in which client can create object on server in cao model?

736


Can you explicitly call a destructor?

690


what is the index value of the first element in an array?

687


What is the difference between inheritance and abstract class?

655


What's the difference between WindowsDefaultLocation and WindowsDefaultBounds?

873


What is an icollection in c#?

668


How many kinds of elements an array can have?

656


Which of the following operations can you not perform on an ado.net dataset?

746


Can an abstract class inherit from another abstract class c#?

730


What is the compiler of c#?

704


How Is The Dll Hell Problem Solved In .net?

772


Explain About DTS package

748