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                      
tip   SiteMap shows list of All Categories in this site.
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
 Microsoft Related AllOther interview questions  Microsoft Related AllOther Interview Questions
Question
What is the Main difference between String and 
StringBuilder and why do we use StringBuilder.
 Question Submitted By :: Bsatish
I also faced this Question!!     Rank Answer Posted By  
 
  Re: What is the Main difference between String and StringBuilder and why do we use StringBuilder.
Answer
# 1
String bulider Can Be Used When More Than One String Can we 
concatenated.
StringBuilder which is more efficient because it does 
contain a mutable string buffer. .NET Strings are immutable 
which is the reason why a new string object is created 
every time we alter it (insert, append, remove, etc.). 

StringBulider Is more Effiecent Then String B'Cuse It 
Provide Some Standered Function like Append,Reverse,Remove
etc.
 
Is This Answer Correct ?    2 Yes 0 No
Dinesh Sharma
 
  Re: What is the Main difference between String and StringBuilder and why do we use StringBuilder.
Answer
# 2
Strings are immutable means Data value maynot be Changed and
Variable value may be changed.
StringBuilder performs is faster than Strings. and also
designed for Mutable Strings
we can use like  this
System.text.StringBuilder
 
Is This Answer Correct ?    2 Yes 0 No
Tharaknlr
[Xyz]
 
 
 
  Re: What is the Main difference between String and StringBuilder and why do we use StringBuilder.
Answer
# 3
String are Immutable (Not Modifiable). If you try to modify 
the string it actually creates a new string and the old 
string will be then ready for garbage collection.

StringBuilder when instantiated, creates a new string with 
predefined capacity and upto that capacity it can 
accodomate string without needing to create a new memory 
location for the string....i mean it is modifiable and can 
also grow as and when needed. 

When the string needs to be modified frequently, preferably 
use StringBuilder as its optimized for such situations.
 
Is This Answer Correct ?    3 Yes 0 No
Sandeep Soni
 
  Re: What is the Main difference between String and StringBuilder and why do we use StringBuilder.
Answer
# 4
Both String and StringBuilder are classes used to
handle the strings.

     The most common operation with a string is
concatenation. This activity has to be performed very
efficiently. When we use the "String" object to concatenate
two strings, the first string is combined to the other
string by creating a new copy in the memory as a string
object, and then the old string is deleted. This process is
a little long. Hence we say "Strings are immutable".

     When we make use of the "StringBuilder" object, the
Append method is used. This means, an insertion is done on
the existing string. Operation on StringBuilder object is
faster than String operations, as the copy is done to the
same location. Usage of StringBuilder is more efficient in
case large amounts of string manipulations have to be performed.
 
Is This Answer Correct ?    2 Yes 0 No
Anandha Kumar T
 
  Re: What is the Main difference between String and StringBuilder and why do we use StringBuilder.
Answer
# 5
String class is immutable, means we can not change the
contents of string at run time,
for example
String s1="loin";
string s2=s1.insert(3,"g");
now s2 have the value login ,but one thing to notice here is
that we are not assigning this value into s1, because it is
not possible in String class
,but if we want to change the contents of s1 then we will
have to take the StringBuilder calss 
because with the help of this class we can change the
contents of same string
examlpe:
String s1="loin";
s1=s1.insert(3,"g");
now s1 is "login"
here we are assigning the value again in s1,
this is the main difference between in string and
stringBuilder class
 
Is This Answer Correct ?    1 Yes 1 No
Vijay Rana
 

 
 
 
Other C Sharp Interview Questions
 
  Question Asked @ Answers
 
What is Abstraction? Tech-Mahindra2
What is the difference between readonly and const Emphasis1
Can an Assembly have multiple versions TCS9
Explain ACID rule of thumb for transactions.  1
localization using windows c#  2
Where is the output of TextWriterTraceListener redirected?  1
How To Maintain Transaction In C#? Phoenix-Technologies1
What is the Difference between value and reference type? Wipro5
Error handling and how this is done ? Digital-GlobalSoft1
What are three test cases you should go through in unit testing? Wipro1
Can you prevent your class from being inherited and becoming a base class for some other classes?  2
What?s a satellite assembly? Visual-Soft2
What?s the role of the DataReader class in ADO.NET connections?  2
What?s class SortedList underneath?  1
from web.config file with connection string who to interact means who to connect in gridview. in my system shows null something error what is the problem Bally-Technologies2
What?s the .NET datatype that allows the retrieval of data by a unique key?  1
What are the collection classes ? Digital-GlobalSoft1
what r arraylist? what the use of Hashtables?  4
In Main function another function is there and to that function if we pass string as parameter ,then that string value is passed by value or reference type? Honeywell3
How can you sort the elements of the array in descending order? Junosource1
 
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