Help us understand the problem. What is going on with this article?

【C#】【自分用メモ】StringBuilderを使用して1,000,000文字高速で格納する

More than 1 year has passed since last update.

研修で作成したものの自分用メモ。
StringBuilderで予めCapacityを指定しておく。
参考:https://dobon.net/vb/dotnet/string/stringbuilder.html

MillionStr.cs
static void Main()
{
    const int LoopCount = 1000000;
    StringBuilder sb = new StringBuilder(LoopCount);
    const string AppendedString = "あ";
    //// ストップウォッチクラス生成
    var sw = new System.Diagnostics.Stopwatch();
    sw.Start();
    for (int i = 0; i < LoopCount; i++)
    {
        sb.Append(AppendedString);
    }
    sw.Stop();
    Console.WriteLine(sw.Elapsed.ToString());
}
d01tsumath
蛎殻町のエンジニャー。
http://d01tsumath.hatenablog.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away