title: Best way to repeat a character in C#
body: <p>What is the best way to generate a string of <code>\t</code>'s in C#</p>
  <p>I am learning C# and experimenting with different ways of saying the same thing.</p>
  <p><code>Tabs(uint t)</code> is a function that returns a <code>string</code> with <code>t</code> amount of <code>\t</code>'s</p>
  <p>For example <code>Tabs(3)</code> returns <code>&quot;\t\t\t&quot;</code></p>
  <p>Which of these three ways of implementing <code>Tabs(uint numTabs)</code> is best?</p>
  <p>Of course that depends on what &quot;best&quot; means.</p>
  <ol>
  <li><p>The LINQ version is only two lines, which is nice.  But are the calls to Repeat and Aggregate unnecessarily time/resource consuming?</p>
  </li>
  <li><p>The <code>StringBuilder</code> version is very clear but is the <code>StringBuilder</code> class somehow slower?</p>
  </li>
  <li><p>The <code>string</code> version is basic, which means it is easy to understand.</p>
  </li>
  <li><p>Does it not matter at all?  Are they all equal?</p>
  </li>
  </ol>
  <p>These are all questions to help me get a better feel for C#.</p>
  <pre><code>private string Tabs(uint numTabs)
  {
      IEnumerable&lt;string&gt; tabs = Enumerable.Repeat(&quot;\t&quot;, (int) numTabs);
      return (numTabs &gt; 0) ? tabs.Aggregate((sum, next) =&gt; sum + next) : &quot;&quot;; 
  }  
  
  private string Tabs(uint numTabs)
  {
      StringBuilder sb = new StringBuilder();
      for (uint i = 0; i &lt; numTabs; i++)
          sb.Append(&quot;\t&quot;);
  
      return sb.ToString();
  }  
  
  private string Tabs(uint numTabs)
  {
      string output = &quot;&quot;;
      for (uint i = 0; i &lt; numTabs; i++)
      {
          output += '\t';
      }
      return output; 
  }
  </code></pre>