problem leads to:StringBuilder sqlquery = new StringBuilder ();
Sqlquery.append ("Select COUNT ([ProductID]) from ~~where [isdelete]= ' F ');
the difference between 1.StringBuilder and stringString aa= "123456";
aa+= "789";StringBuilder text=new StringBuilder ("123456", 12);
Text. Append ("789");If you output AA, and text you will find that their output content is the same. But the operation of AA is actually: first allocate an address space in memory, the space size is 6.
Then execute aa+= "789", the procedure is the connection string, "123456" and "789" and the address is reassigned in memory. Point the memory address of the AA to the memory address of "123456789".
That is, in memory is actually two space is allocated, the first memory space, in the later is the C # garbage processing mechanism to automatically dispose of,If we use 3 4 sentences to implement this process, then he does not allocate memory space again, he is in the text of the memory space in the operation. Here to illustrate that the next StringBuilder in the process of life variables can be our own to allocate his size, if the actual content beyond the memory space, he will automatically double. From The above example, we can know that the superiority of StringBuilder is in:
First: He doesn't need to allocate memory space every time. Therefore, the system does not need to deal with garbage;
Second: When we need to do multiple operations on a string multiple times, he is much more efficient than string 2.Append The Append method can be used to add a string representation of text or an object to the end of a string represented by the current StringBuilder object.
Stringbuilder.append appends the information to the end of the current StringBuilder. Stringbuilder.appendformat replaces the format specifier passed in the string with the formatted text.
Stringbuilder.insert Inserts a string or an object into the current StringBuilder object at the specified index.
Stringbuilder.remove removes the specified number of characters from the current StringBuilder object.
C # StringBuilder, String, Append