Insert whitespace in a string

JamesBrian
JamesBrian used Ask the Experts™
on
Hi all,

as a former VB programmer, I know VB has the Space()
Example : mystring ="Test" & Space(20) & "rest of the string"
results in :
"Test                   rest of the string"

What is the equivalent of Space() in C# ?

thx,

JB
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Senior Systems and Integration Developer
Commented:
Probably:

    string myString = string.Concat("Test", new String(' ', 20), "Rest of the string");
Commented:
try this:
mystring ="Test" + new String(‘ ‘, 20) + "rest of the string";
Commented:
lol.. same time

Author

Commented:
carl_tawn got it first, but I'll reward you both for the exact same answers at almost the exact same time....

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial