What is the difference between System.String and
System.StringBuilder classes?

Answers were Sorted based on User's Feedback



What is the difference between System.String and System.StringBuilder classes?..

Answer / anonymous

The performance of your program is improved by using String
builder. When trying to concatenate old string + new
string...A new memory is allocated for the new string and
the old one is copied onto the new one. This is quite a
lengthy procedure, though it happens internally, it will
have a major impact on the performance of your program. To
overcome, this problem you can go for String builder.

Is This Answer Correct ?    23 Yes 0 No

What is the difference between System.String and System.StringBuilder classes?..

Answer / bhaskar

system.string is immutable and system.stringbulider can have
mutable string where a verity of operations can be performed

Is This Answer Correct ?    13 Yes 1 No

What is the difference between System.String and System.StringBuilder classes?..

Answer / davender arora

sytem.string is immutable it means if we r performing
string manipulations new memory is allocated each time
eg:string a=dev; a=arora; in this case new memory is
created a=arora and previously a=dev wil be deleted.so
major impact on performance but string builder is mutable
so same memory wil be updated for the same so good
performance.

Is This Answer Correct ?    5 Yes 1 No

What is the difference between System.String and System.StringBuilder classes?..

Answer / shyam vishwakarma

String and StringBuilder class stores strings. But when you
cannot change a String object after creating one.
eg: String name = "Prasad";
By saying you cannot change the name object means you cannot
change the value in name object internally. When you change
the name object value to something else, a new String object
is creating in memory and assign the new value.

eg: name = "Prasad Reddy";

A new name object is creating in memory and the value
"Prasad Reddy" is assinging to the newly created space.

But StringBuilder class occupies the same space even if you
change the value.

If you are doing string concatenation StringBuilder class is
far better in performance than String class.

You can use StringBuilder's Append() method to use
concatenation.

Is This Answer Correct ?    2 Yes 0 No

What is the difference between System.String and System.StringBuilder classes?..

Answer / chauhan rakesh

System.String is immutable; System.StringBuilder was
designed with the purpose of having a mutable string where a
variety of operations can be performed.

String is immutable.A new object is create if a string needs
to be modified.
While string builder object can be modified without creating
a new object.
stringbuilder class offers various methods like replace etc.

IN System.String
1.String is built in class in .net base classes.
2.In this we can do all the string operation like
substring,strcpy etc
but cant do editing .so thats called immutable.
3.System.StringBuilder class have ability of append function
that not available in Sting class

String..
1.Its a class used to handle strings.
2.Here concatenation is used to combine two strings.
3.String object is used to concatenate two strings.
4.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
5.we say "Strings are immutable".

String Builder..
1.This is also the class used to handle strings.
2.Here Append method is used.
3.Here, String builder object is used.
4.Insertion is done on the existing string.
5.Usage of String Builder is more efficient in case large
amounts of string manipulations have to be performed

string builder is used for many variety of operations
string cannot be used for that many operation

Is This Answer Correct ?    2 Yes 0 No

What is the difference between System.String and System.StringBuilder classes?..

Answer / mukesh

System.String is immutable. If your programe is going
concate more then two string then String class can do this
work easily but decrease programe funcationlity. This is
because when you are concate string that time it takes a
new momory allocated. But when you are using StringBuilder
then there is no new memory allocation.

Is This Answer Correct ?    1 Yes 0 No

What is the difference between System.String and System.StringBuilder classes?..

Answer / gyana

In System.String only pass the things simply,but in
System.StringBuilder classes, it builds the class
first,then after another.

Is This Answer Correct ?    2 Yes 2 No

What is the difference between System.String and System.StringBuilder classes?..

Answer / chauhan rakesh botad

System.String is immutable; System.StringBuilder was
designed with the purpose of having a mutable string where a
variety of operations can be performed.

String is immutable.A new object is create if a string needs
to be modified.
While string builder object can be modified without creating
a new object.
stringbuilder class offers various methods like replace etc.

IN System.String
1.String is built in class in .net base classes.
2.In this we can do all the string operation like
substring,strcpy etc
but cant do editing .so thats called immutable.
3.System.StringBuilder class have ability of append function
that not available in Sting class

String..
1.Its a class used to handle strings.
2.Here concatenation is used to combine two strings.
3.String object is used to concatenate two strings.
4.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
5.we say "Strings are immutable".

String Builder..
1.This is also the class used to handle strings.
2.Here Append method is used.
3.Here, String builder object is used.
4.Insertion is done on the existing string.
5.Usage of String Builder is more efficient in case large
amounts of string manipulations have to be performed

string builder is used for many variety of operations
string cannot be used for that many operation

Is This Answer Correct ?    0 Yes 0 No

What is the difference between System.String and System.StringBuilder classes?..

Answer / gyana

In System.String only pass the things simply,but in
System.StringBuilder classes, it builds the class
first,then after another.

Is This Answer Correct ?    0 Yes 4 No

Post New Answer

More C Sharp Interview Questions

What is the difference between selection and projection?

0 Answers  


What is Co- and Contra-Variance in C#?

0 Answers  


Explain about accessibility modifier 'protected internal'?

0 Answers  


What is the difference between <c> and <code> xml documentation tag?

0 Answers  


Hi all,I am the beginner. Please tell use of finally block.

6 Answers   IBM,






What is dependency injection?

0 Answers  


What is the advantage of generics in c#?

0 Answers  


Why we put script in head of asp.net page Why not in body?

1 Answers  


Whats an assembly? Describe the importance of assembly?

0 Answers   Siebel,


What is difference between struct and class in c#?

0 Answers  


What is the signature of a method?

0 Answers  


What is the difference between an integer and int?

0 Answers  


Categories