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
How can we implement a identity (sql server) call in an asp.net page?
Explain the significance of routing? : asp.net mvc
Explain the difference between value type and reference type?
What are the new navigation controls in asp.net 2.0?
Which method do you use to enforce garbage collection in .net?
What is the difference between user control and custom control?
Explain client side state management system.
I am trying to implement sorting facility from client side code in GridView Control. So how can I fill up an Array inside client side code (using JavaScript), i want to assign my DataSet object declared and filled up on Server side(in code behind) to the array (on client side)
What are the different web pages?
What are client activated objects?
How do we ensure view state has not tampered?
What is a server cookie?
How can u deifne the benefits and limitation of using Viewstate for state management?
Which object is used to encapsulate the state of the client and the browser in ASP.NET?
What is meant by ispostback in asp net?