Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


Is string reference type / value type?

Answers were Sorted based on User's Feedback



Is string reference type / value type?..

Answer / charlie

In this part of the C# docs, a string is explicitly named
as a reference type:

http://msdn.microsoft.com/en-us/library/490f96s2.aspx

Is This Answer Correct ?    3 Yes 0 No

Is string reference type / value type?..

Answer / sunil

string is a 1000% reference type

Is This Answer Correct ?    3 Yes 0 No

Is string reference type / value type?..

Answer / kris cassidy

I am so much better than all of you a string is an
amalgomation of cotton and wool, not to be confused with
cotton wool, strings irregular cousin!

Is This Answer Correct ?    3 Yes 0 No

Is string reference type / value type?..

Answer / frank

This is the stupidest thread I've seen in many years of surfing the internet, and the stupidest discussion I've witnessed in even more years of software development. All you value type string proponents should start your own club and go hang out with the flat earth society.

Is This Answer Correct ?    2 Yes 0 No

Is string reference type / value type?..

Answer / mathew

I am confused,
Microsoft in one site says "String is a reference type".
Check the below website
http://msdn.microsoft.com/en-us/library/362314fe.aspx
It says
"Although string is a Reference type, the equality
operators (== and !=) are defined to compare the values of
string objects, not references. This makes testing for
string equality more intuitive".

while when checked the other website
http://msdn.microsoft.com/en-us/library/83fhsxwc.aspx
Which list's "Built-In Types Table (C# Reference)" which has
STRING in the list

C# Type .NET Framework Type
--------- ---------------------
bool System.Boolean
byte System.Byte
sbyte System.SByte
char System.Char
decimal System.Decimal
double System.Double
float System.Single
int System.Int32
uint System.UInt32
long System.Int64
ulong System.UInt64
object System.Object
short System.Int16
ushort System.UInt16
string System.String

And it is mentioned
"All of the types in the table, except OBJECT and STRING,
are referred to as simple types."

From all these I infer that "STRING is a reference type".

Is This Answer Correct ?    2 Yes 0 No

Is string reference type / value type?..

Answer / rachel p

The above code sample doesn't prove anything, except that
Malli's code is full of bugs! You've a line in there that
contains the following error:

Console.WriteLine("StrName1=" + StrName2);

for goodness sake! And that's by no means the only error in
logic/reasoning.

String *is* a Reference Type, however, for many of the good
reasons established by previous answers.

Is This Answer Correct ?    1 Yes 0 No

Is string reference type / value type?..

Answer / arun

String is REFERENCE TYPE

Is This Answer Correct ?    1 Yes 0 No

Is string reference type / value type?..

Answer / praseetha sandeep

100% sure string is reference type....

Is This Answer Correct ?    1 Yes 0 No

Is string reference type / value type?..

Answer / guru dayal roy

String is reference type. When we define a string and
initialise it creats an object and again when we try to
append something it creates a new object which contains
both the string togather. So since string initialization
creates an object we can say string is also reference type
which does not happen with other value types.

Is This Answer Correct ?    1 Yes 0 No

Is string reference type / value type?..

Answer / pradeep chouhan

Hi Friends,

string is a reference type.

kindly go through below code.

string str1 = "1";
Response.Write(str1+"<br/>"); //output: 1
string str2 = str1;
str2="2";
Response.Write(str1+"<br/>"); //output: 1 (instead of 2)

Bcos of this behavior of string most of the people think
string is a value type. but the actual mystery lies on the
3rd line of the above code ie string str2 = str1; Always
remember '=' assignment operator is overloaded by default
for string. so when str2 = str1 this means a copy of str1 is
assigned to str2 instead of its reference.

I think now the idea is clear.

Is This Answer Correct ?    1 Yes 0 No

Post New Answer

More C Sharp Interview Questions

Can abstract class have constructor c#?

0 Answers  


What are assemblies?

0 Answers   Microsoft,


explain synchronous and asynchronous in C#

3 Answers   AxSys, Mastek, Synechron,


when data member or member function is static is acess specifier is considered??

2 Answers  


What are delegate methods?

0 Answers  


What is difference between hashtable and dictionary in c#?

0 Answers  


Can I call a virtual method from a constructor/destructor?

0 Answers  


Is it possible to inline assembly or il in c# code?

0 Answers  


why do we use Overloading, Overriding, Boxing, Unboxing, and what is the use of these ?

3 Answers   eXensys,


FOR EXAMPLE : CLASS Dotnet { } creating object: Dotnet dn=new Dotnet(); NOW THE QUESTION IS WHICH IS CALLED AS OBJECT ? EITHER dn OR new Dotnet() and CAN YOU PROVE YOUR ANSWER????? PLEASE REPLY...

2 Answers  


What is c# console application?

0 Answers  


Define using statement in c#?

0 Answers  


Categories