What is the Main difference between String and
StringBuilder and why do we use StringBuilder.
Answer Posted / vijay rana
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 ? | 43 Yes | 27 No |
Post New Answer View All Answers
How can it prevents DLL Hell assembly versioning in .NET?
What is delegates in c#?
Explain the difference between abstract class and interface.
What is private and shared assembly?
If I have more than one version of one assemblies, then how'll I use old version (how/where to specify version number?)in my application?
Explain about ODP.net
Explain About Global.asax
Difference between debug.write and trace.write?
How do I declare a pure virtual function in c#?
What Is The Difference Between The System.array.copyto() And System.array.clone()?
Describe the process of “exception handling implementation” in c#?
Is array passed by reference in c#?
How many types of constructors are there?
Explanation on Generic?
What is event and delegates in c#?