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

Is c# used for any core features of windows vista?

0 Answers  


There are a class A. Another class B derived from it. Now if I do A a = new B(); and B b = new B(); What will happen in both the statements. And what is the difference between these two statements.

3 Answers   HCL,


What is a lambda expression in c#?

3 Answers  


Can u list some style properties of List Box?

0 Answers   CGI,


What is a generic in c#?

0 Answers  


Illustrate namespaces in c#?

0 Answers  


How to use delegates with events?

0 Answers  


Describe the parts of assembly.

0 Answers  


What is datagridview in c#?

0 Answers  


What is dictionary collection in c#?

0 Answers  


What is ENUM?

10 Answers   TCS, Wipro, YeshTech,


Define constructors

0 Answers  


Categories