2009-05-22 14:37:50 +00:00
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
namespace Jellyfish.Library
|
|
|
|
|
{
|
|
|
|
|
public static class StringBuilderExtensions
|
|
|
|
|
{
|
|
|
|
|
public static StringBuilder AppendWithoutGarbage(this StringBuilder builder, int number)
|
|
|
|
|
{
|
|
|
|
|
if (number < 0)
|
|
|
|
|
{
|
|
|
|
|
builder.Append('-');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int index = builder.Length;
|
|
|
|
|
do
|
|
|
|
|
{
|
2009-06-01 10:34:24 +00:00
|
|
|
|
builder.Insert(index, Digits, (number % 10) + 9, 1);
|
2009-05-22 14:37:50 +00:00
|
|
|
|
number /= 10;
|
|
|
|
|
}
|
|
|
|
|
while (number != 0);
|
|
|
|
|
|
|
|
|
|
return builder;
|
|
|
|
|
}
|
|
|
|
|
|
2009-06-01 10:34:24 +00:00
|
|
|
|
private static readonly char[] Digits = new char[] { '9', '8', '7', '6', '5', '4', '3', '2', '1', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' };
|
2009-05-22 14:37:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|