Strings.Space(Int32) Method

Definition

Returns a string consisting of the specified number of spaces.

C#
public static string Space(int Number);

Parameters

Number
Int32

Required. Integer expression. The number of spaces you want in the string.

Returns

A string consisting of the specified number of spaces.

Exceptions

Number < 0.

Examples

This example uses the Space function to return a string consisting of a specified number of spaces.

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

Remarks

The Space function is useful for formatting output and clearing data in fixed-length strings.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also