Geeks With Blogs
hmloo's World of .NET April 2012 Entries
How to remove the last character from Stringbuilder
We usually use StringBuilder to append string in loops and make a string of each data separated by a delimiter. but you always end up with an extra delimiter at the end. This code sample shows how to remove the last delimiter from a StringBuilder. using System; using System.Collections.Generic; using System.Text; using System.Linq; class Program { static void Main() { var list =Enumerable.Range(0, 10).ToArray(); StringBuilder sb = new StringBuilder(); foreach(var item in list) { sb.Append(item).Append(","); ......

Posted On Sunday, April 8, 2012 12:12 PM

Copyright © hmloo | Powered by: