Right-aligns the characters in this instance, padding on the left with spaces or a specified Unicode character for a specified total length. Overload ListRight-aligns the characters in this instance, padding with spaces on the left for a specified total length. Supported by the .NET Compact Framework. [Visual Basic] Overloads Public Function PadLeft(Integer) As String [C#] public string PadLeft(int); [C++] public: String* PadLeft(int); [JScript] public function PadLeft(int) : String; Right-aligns the characters in this instance, padding on the left with a specified Unicode character for a specified total length. Supported by the .NET Compact Framework. [Visual Basic] Overloads Public Function PadLeft(Integer, Char) As String [C#] public string PadLeft(int, char); [C++] public: String* PadLeft(int, __wchar_t); [JScript] public function PadLeft(int, Char) : String; Example[Visual Basic, C++, JScript] The following code example demonstrates the PadLeft method. [Visual Basic, C++, JScript] Note This example shows how to use one of the overloaded versions of PadLeft. For other examples that might be available, see the individual overload topics. [Visual Basic] Dim str As String Dim pad As Char str = "forty-two" pad = "."c Console.WriteLine(str.PadLeft(15, pad)) ' Displays "......forty-two". Console.WriteLine(str.PadLeft(2, pad)) ' Displays "forty-two". [C++] String *str = L"forty-two"; Console::WriteLine(str-> PadLeft(15, L'.')); // Displays "......forty-two". Console::WriteLine(str-> PadLeft(2, L'.')); // Displays "forty-two". [JScript] var str : String; var pad : char; str = "forty-two"; pad = "."; Console.WriteLine(str.PadLeft(15, pad)) // Displays "......forty-two". Console.WriteLine(str.PadLeft(2, pad)) // Displays "forty-two". [C#] No example is available for C#. To view a Visual Basic, C++, or JScript example, click the Language Filter button in the upper-left corner of the page. See AlsoString Class | String Members | System Namespace Syntax based on .NET Framework version 1.1. Documentation version 1.1.1. |
|
來自: ThinkTank_引擎 > 《C#》