Difference between string class & stringbuilder class in c#
Can any one please explain Difference between string class and stringbuilder class in c#
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Jan 29, 2015, 11:27 PM EST
Main Differences between String and StringBuilder
String
StringBuilder
String is immutable, meaning that once you created string object then you can't modify it
StringBuilder is mutable, meaning that once you created string builder object then you can modify or append without creating a new instance for every time
Any operation that appears to change the string, it creates a new instance of string type in memory
Any operation that appears to modify or append new string, it doesn't create a new instance of string type in memory
Required Class is System.String
Required Class is System.Text.StringBuilder
Required Namespace is System
Required Namespace is System.Text
String is slower as compare to string builder object when we deals with large size of strings
StringBuilder is faster as compare to string object when we deals with large size of strings
String is efficient when we deals with static or smaller size of string means we don't need to modify later on
StringBuilder is efficient when we deals with dynamic or larger size of string means we want to modify that string later on
Ezhil arasan34 reputationPosted Jan 30, 2015, 12:02 AM EST