Is string reference type / value type?

Answer Posted / malli

String Is Reference Type Ex

string StrName1 = "Test";
string StrName2 = StrName1;
StrName2="Test1";
Console.WriteLine("StrName1="+StrName1);
Console.WriteLine("StrName1=" + StrName2);

Object objStrName1 = "Test";
Object objStrName2 = objStrName1;
objStrName2 = objStrName1;
objStrName2 = "Test1";
Console.WriteLine("objStrName1=" + objStrName1);
Console.WriteLine("objStrName2=" + objStrName2);
Console.WriteLine("Malli");

OutePut:-

StrName1=Test
StrName1=Test1
objStrName1=Test
objStrName2=Test1

No More Discusion...

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the components of window?

510


What is hash c#?

506


Can I use ReaderWriterLock instead of Monitor.Enter/Exit for Threading?

525


What is difference between assembly and dll?

491


Explain when should you call the garbage collector in .net?

496






Distinguish between a class and struct?

521


What are c# attributes and its significance?

533


How does foreach loop work in c#?

491


What is yield return in c#?

499


Hi to all..I have to create an intranet application on C#.NET windows Application so please please let can you people help me as iam new in .NET and if u have any samples or website address from where i can get sample please let know.

3809


Why do we use generics in c#?

546


Can constructor be protected?

475


What are the extension methods in c#?

506


Are structs faster than classes?

544


Can arraylist hold primitive types?

551