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 a value type or a reference type?

Answer Posted / benjamin janecke

String is a reference type but it behaves somewhat like a
value type. So it's a bit tricky and many developers don't
know it.

Great care should be taken when doing excessive string
manipulations with the String class. As already posted,
each String is read only and can never be changed. Thus,
every manipulation creates a new instance (and causes the
garbage collector to remove old ones) which can have a
dramatic performance impact on an application. Therefore,
always use the StringBuilder class in these scenarios,
which holds only one representation of a string in memory
and performs any changes directly to that memory block.

Btw. for those who don't belive String is a reference type,
just refer to MSDN or run ILDASM und load the mscorlib.dll
module from the .NET Framework. Then go to System.String
and u'll notice it's directly inherited from System.Object -
contrary to, for instance, the System.Byte class which is
inhertied from System.ValueType, meaning Byte is a value
type, String is not.

Is This Answer Correct ?    36 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why do I get error message "could not load type" whenever I browse to my asp.net web site?

1097


Why will you usually create an aspnet user account in the database for an asp.net web application?

959


How to prevent client side validation from the ASP.NET validation controls?

1020


What is a pixel url?

874


What are type/key pairs in client script registration?

997


How to find out what version of asp.net I am using on my machine?

1051


How can we prepairing Interview

2286


Give a few examples of page life cycle events.

1075


Explain the advantages of asp.net.

938


What is the difference between “Web.config” and “Machine.Config”?

1084


What I need to create and run an asp.net application?

930


What is a server cookie?

949


Explain how cookies work. Give an example of cookie abuse.

1053


How do you declare static variable? What is its lifetime?

914


hi .net gurus. plz if any one has dumps on 70-631 and 70-541 on windows sharepoint services kindly mail me.

1608