Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8397835
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:53:21+00:00 2026-06-09T20:53:21+00:00

After searching the web and reading docs on MSDN, I couldn’t find any examples

  • 0

After searching the web and reading docs on MSDN, I couldn’t find any examples of how to replicate a tab character in C#. I was going to post a question here when I finally figured it out…

I’m sure it is obvious to those fluent in C#, but there were SO many similar questions in various forums, I thought an example was worth posting (for those still learning C# like me). Key points:

  1. use “double-quotes” for a string
  2. use ‘single-quotes’ for a char
  3. \t in a string is converted to a tab: "John\tSmith"
  4. '\t' by itself is like a tab const

Here is some code to add tabs to the front of an HTML line, and end it with a newline:

public static string FormatHTMLLine(int Indent, string Value)
{
  return new string('\t', Indent) + Value + "\n";
}

You could also use:

string s = new string('\t', Indent);

Is this the most efficient way to replicate tabs in C#? Since I’m not yet ‘fluent’, I would appreciate any pointers.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:53:22+00:00Added an answer on June 9, 2026 at 8:53 pm

    Yes, I think this is the best way.

    The string constructor you are using constructs a string containing the character you specify as the first argument repeated count times, where count is the second argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After days of searching the web (Including MSDN) for a way to get Hardware
After searching online and reading the Oracle documentation for this, I need some help
After searching I dd not find anything about glassfish3.1 and CORS Is it possible
After searching online and going through past stackoverflow posts for a suitable implementation for
After searching a lot i did not get any answers and finally i had
After searching, I dont find the appropriate way to resolve following problem. After activating
I am trying to understand how classpath really works. After searching around the web
After trying many and searching web option to compile and load dll I could
After searching around the web for about half an hour i've decided to ask
I'm asking this question after searching the web for an answer for 2 days.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.