Space() in VB Strings Class and its Equivalent in C#

 

The Below code Demonstrates the use of the Space() function in the Microsoft.VisualBasic.Strings Class

Dim Test As String  ' Returns a string with 10 spaces.
TestString = Space(10)
' Inserts 10 spaces between two strings.
TestString = "Hello" & Space(10) & "World"

So Using this function maynot be supported in certain cases so here is an equivalent that can be used in c#

string s = “Test”;

s = s.PadLeft(2, ” “); // adds leading 2 space

s=”  Test”;

s = s.PadRight(2, ” “); // Toadd spaces to the Right

s=”Test  “

Is s=””;

It becomes “  “

insert the space in the position you want to .

TestString=”Hello”+S+”World”;

Enjoy Coding.