padRight Summary Pads the string with spaces from the right until it reaches the specified width (number of characters). Signatures Click on a signature to select it and view its documentation. public string padRight(int width) public string padRight(int minWidth, string fillWith) Usage public string padRight(int width) public string padRight(int minWidth, string fillWith) Returns The string with spaces appended until it reaches the specified width. The string with the specified substring appended until it reaches at least the specified minimum width. Parameters width The width (number of characters) to expand the string to. Parameters minWidth The minimum width (number of characters) to expand the string to. fillWith The string to insert until the specified minimum width is reached. Description Inserts spaces at the end of the string until it reaches the specified width (number of characters). If the string already equals or exceeds the specified width (number of characters), nothing will happen. Inserts the specified fillWith string at the end of the string until it reaches at least the specified minimum width (number of characters). If the string already equals or exceeds the specified minimum width (number of characters), nothing will happen. If the length of the fillWith string is not a multiple of the specified minimum width, the result may exceed the specified minimum width. Examples Basic Usage 123456import System; string a = "a";Console.log(a.padRight(4)); // "a "Console.log(a.padRight(1)); // "a"Console.log(a.padRight(2)); // "a " Zero Filling from the Right 12345import System; string one = "1";string zeroFilled = one.padRight(4, "0");Console.log(zeroFilled); // "1000" Share HTML | BBCode | Direct Link