How to add SPACES to a string variable
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Dec 20, 2009, 10:39 PM EST
There is no special method to do that.
You can simply add a space.
string a = " ";
string b = "abc" + a + "xyz";
Or you can use PadLeft, PadRight functions.
If you want to add a tab then you can do the following.
string a = "\t";
string b = "abc" + a + "xyz";
If this is helpful to you, please check 'Do you like this answer' checkbox.
Hiren SoniRank #694 · 3.5K reputationPosted Dec 21, 2009, 1:55 AM EST
paul daniel189 reputationPosted Dec 30, 2009, 4:01 AM EST
see this eg:
string s1 = "VM";
s1 = s1 + " ";
~ or ~
string s1 = "VM";
string s2 = s1 + " ";
Raunak Jhawar51 reputationPosted Dec 30, 2009, 4:23 AM EST
Raunak Jhawar51 reputationPosted Dec 30, 2009, 4:23 AM EST