c# create an arbitrary length generic parameter string e.g. ?,?,?

Posted by Sky Sanders on Stack Overflow See other posts from Stack Overflow or by Sky Sanders
Published on 2010-03-30T06:26:27Z Indexed on 2010/03/30 6:33 UTC
Read the original article Hit count: 244

Filed under:
|

I know I am forgetting to remember how to do this and it is late.

I want to, in an elegant manner, build a placeholder list for a munged sql command.

Have a command with an arbitrary number of parameters, need to build ?,?,?

Did I mention that it was a wet brain fart? this is what came out:

Regex.Replace(new string('?', _command.Parameters.Count), @"\?\?", @"\?,\?");

You are welcome to make me feel like more of an idiot if you just remember me what I am forgetting. ;-)

© Stack Overflow or respective owner

Related posts about string-manipulation

Related posts about c#