Is string a value type or a reference type?

Answer Posted / rajneesh hajela

string is immutable

but stringbuildler are mutable...

this play many role


StringBuilder y = new StringBuilder();
y.Append("hello");

StringBuilder x = new StringBuilder();
x.Append("hello");

if (y == x)
{
}
// Stirng is immutable .In some ways it to
be value types .These are known as immutable .
//===================

string str1 = "hello";
string str2 = "hello";

if (str1 == str2)
{
}
//===============
string y1 ="";
y1="hello";

Program p = new Program();
p.foo(ref y1);
Console.WriteLine(y1);

}

void foo(ref string sb)
{
sb="Rajneesh Hajela:";
}


Rajneesh Hajela

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 implement CAS in .Net?

2626


What is clr in .net?

873


What are an object and a class?

787


Please explain what are an inheritance, polymorphism, and encapsulation?

852


What is typical about a windows process in regards to memory allocation in dot net?

846


Please explain what is the .net framework and how does it work?

751


Explain what is the difference between constants and read-only variables?

755


What is the difference between a class and an object, and how do these terms relate to each other?

810


What is 3 tier architecture?

793


Differentiate between 'DataSet' and 'SQLDataReader' in ADO.NET?

836


What is RCW (Run time Callable Wrappers)?

2175


what is the default security setting in .net?

768


What is namespace in .net?

840


What is value type and refernce type in .net?

845


What is heap and what is stack?

821