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".
6.. system.string is non updatable.
stringbuilder
7.string
everytime a object has to be created for Operations like
append,Insert etc. at runtime
1. system.stringbuilder is updateble.
2.string builder is faster than the string object.
3.String builder is more efficient in case large amount of string operations have to be perform.
4.String builder is mutable means we can able to re size the memory size
5.Insertion is done on the existing string.
6.System.stringbuilder is used to dynamic strings
Example
class Program
{
static void Main(string[] args)
{
//for example:
string str = "hello"; //Creates a new object when we concatenate any other words along with str variable it does not actually modify the str variable, instead it creates a whole new string.
str = str + " to all";
Console.WriteLine(str);
StringBuilder s = new StringBuilder("Hi");
s.Append(" To All");
Console.WriteLine(s);
Console.Read();
}
}
Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator