ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
Do you have a collection of Interview Questions and interested to share with us!!
Please send that collection to along with your userid / name. ThanQ
Google
 
Categories  >>  Software  >>  Microsoft Related  >>  C Sharp
 
 


 

 
 Visual Basic interview questions  Visual Basic Interview Questions
 C Sharp interview questions  C Sharp Interview Questions
 ASP.NET interview questions  ASP.NET Interview Questions
 VB.NET interview questions  VB.NET Interview Questions
 COM+ interview questions  COM+ Interview Questions
 ADO.NET interview questions  ADO.NET Interview Questions
 IIS interview questions  IIS Interview Questions
 MTS interview questions  MTS Interview Questions
 Crystal Reports interview questions  Crystal Reports Interview Questions
 BizTalk interview questions  BizTalk Interview Questions
 Dot Net interview questions  Dot Net Interview Questions
 Exchange Server interview questions  Exchange Server Interview Questions
 SharePoint interview questions  SharePoint Interview Questions
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
Whats the use of string builder?
 Question Submitted By :: Kayalvizhy
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Whats the use of string builder?
Answer
# 1
Since C# strings are immutable, an existing string cannot 
be modified. So, if one tries to change a string either 
with the concatenation operator (+) or with the Insert, 
PadLeft, PadRight, Replace, or SubString methods, an 
entirely new string is created—leaving the original string 
intact. 

Therefore, operations which would alter strings—instead—
cause additional memory to be allocated. Memory is a scarce 
resource. And, memory allocations are expensive in terms of 
memory and performance. Consequently, sometimes String 
class usage should be avoided. 

The StringBuilder class is designed for situations when one 
needs to work with a single string and make an arbitrary 
number of iterative changes to it. Many StringBuilder class 
methods are the same as those of the String class. However, 
the string content of a StringBuilder class can be changed 
without the necessity of allocating additional memory. 
Thus, operations on the StringBuilder class will be much 
faster than operations on the String class in certain 
situations. Paradoxically, just the the opposite can be 
true in other situations. 

The String class is optimized and quite efficient for most 
cases. On the other hand, if strings must be modified, then 
the String class can be a real resource waster. It must be 
appreciated that the String class is really very 
intelligent in its memory handling in most everyday 
programming situations. 

Instead of the String class, use the StringBuilder class 
when a single string must be modified repeatedly.
 
Is This Answer Correct ?    1 Yes 0 No
Kishoreg
 

 
 
 
Other C Sharp Interview Questions
 
  Question Asked @ Answers
 
How to make a class non-inheritable other than sealed?  3
what is the difference between finally and dispose methods? HCL3
Why would you use untrusted verificaion?  1
What debugging tools come with the .NET SDK? CorDBG  1
What?s a delegate?  2
An abstract class is inherited, an Interface also inherited(multiple inheritance), How it differences. Synechron1
localization using windows c#  2
Code to run exe like mspaint,autocad etc in asp.net.  1
What is Dispose method in .NET?  1
What?s the difference between an interface and abstract class?  4
write code for Factorial? Tech-Mahindra5
If u declare two interfaces withsame methodnmae .prototype how can u call the particular method from class? Microsoft4
What is the wildcard character in SQL? Let?s say you want to query database with LIKE for all employees whose name starts with La.  1
What are STA And MTA in threading? Kanbay3
why C++ Partial Object Oriented Programming Language and C# and Java Fully Object Oriented Language TCS4
What?s the data provider name to connect to Access database?  5
If I want to override a method 1 of class A and in class b then how do you declare ? MMTS2
What?s the advantage of using System.Text.StringBuilder over System.String?  1
What’s difference between Association, Aggregation and Inheritance relationships? TCS1
What interface do you implement in order to provide a user of your class deterministic, destructor-like cleanup?  1
 
For more C Sharp Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com