Difference Between String and Stringbuilder using C#
Today, We want to share with you Difference Between String and Stringbuilder using C#.
In this post we will show you Difference between string and StringBuilder in c#, hear for Difference between string and StringBuilder we will give you demo and example for implement.
In this post, we will learn about what is the difference between string and stringbuilder in c#? with an example.
Difference between string and StringBuilder in c#
In this post,we will learn about Difference between string and StringBuilder in C# with an example.
Now in this post, I will explain about Difference between string and StringBuilder in C# with appropriate example. StringBuilder and string both use to store and manage string value in variable but both have many differences on the bases of instance creation and also for performance.
String data type is an immutable object. So, When we create string object in program, we cannot change that object in any operations viz. insert new value, replace or append any value with existing value in string object, when we have to do some operations to change string simply it will dispose the old value of string object and it will create new instance in memory for storing the new value in string object.
System.Text.Stringbuilder is mutable object which also hold the string value, mutable refer to once we create a System.Text.Stringbuilder object we can use this object for any operation like insert value in existing string with insert functions also replace or append without creating new instance of System.Text.Stringbuilder for every time so it’s use the previous object so it’s work fast as compare than System.String.
I hope you get an idea about C# – Difference between String and Stringbuilder in C#, Asp.net.
I would like to have feedback on my Infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.