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

Which namespace is used to support multithearding in .NET?

780


If we write any code for DataGrid methods, what is the access specifier used for that methods in the code behind file and why?

1817


Name the classes that are introduced in the system.numerics namespace.

849


Explain the differences between server-side code and client-side code.

777


Explain how to load the contents of an xml file into an xmldocument object?

749


What are the new features in .net core?

784


Explain garbage collection?

735


Write the .net syntax for 'for loop'?

767


What is the difference between override and overload in a method?

750


Is .net core free?

842


Which namespace does it belong to by default?

787


What is the concept of inheritance in .net?

831


What is meant by globalization?

777


Why inheritance is important?

779


What is a variable of implicit type and what is its scope?

715