The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,164 other followers

Repeating characters into strings in C# and Delphi (via: .net – Best way to repeat a character in C# – Stack Overflow)

Posted by jpluimers on 2012/06/26

Switching back and forth between mainly Delphi and C#, sometimes it is hard to remember which idiom works best in each environment.

Recently, I had to dupe a lot of tab characters for some Tab-Delimited interface to an archaic system.

I remembered the Delphi idiom: use the DupeString function as about Delphi explains (yes, I know: it dupes more than just characters).

In C#, these work best for me:

Small code sample of the first way (thanks CMS):

static string Tabs(int n)
    return new String('\t', n);


via: .net – Best way to repeat a character in C# – Stack Overflow.

Oh BTW: I have reduced my StackOverflow presence. It looks like the success of StackOverflow made them instantiate many moderators. A lot of those moderators work under the mantra “we follow the rules strictly, and favour punishment over encouragement” (some  even talk about “changing heritage“). That’s a real pity, as I see a lot of StackOverflow users get scared by the very active downvoting, question/answer closing and even deletion of material that is in essence valuable, if it were edited up a bit. Deleting content is always bad, as it increases the link rot that StackOverflow are trying to prevent in questions/answers as per their FAQ. Links are the foundation of the web.

Alas, devoting real attention to the quality of StackOverflow requires putting real energy in it, which for some of the moderators seems to be too much to ask.

5 Responses to “Repeating characters into strings in C# and Delphi (via: .net – Best way to repeat a character in C# – Stack Overflow)”

  1. A. Bouchez said

    On Delphi, I would better use “StringOfChar” instead, which is dedicated to repeating characters, is available in all Delphi versions, and part of System.pas.

    About SO, I feel a bit the same. But we have to face the fact that some questions are very vague. Sometimes, you’ll have to guess what was asked. Need to be crystal-ball gazers. ;)

  2. Eric said

    I had noticed that trend at SO too, which came on top of the IMHO annoying one of splitting stuff across other sites (programmersexchange, etc.) which need separate registration, don’t have easy merging/redirection of questions, etc.
    Time is ripe for a new service to emerge I guess.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: