String.PadRightとは? わかりやすく解説

String.PadRight メソッド (Int32)

この文字列文字左寄せし、指定され文字列長さになるまで、右側空白埋め込みます。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Function PadRight ( _
    totalWidth As Integer _
) As String
Dim instance As String
Dim totalWidth As Integer
Dim returnValue As String

returnValue = instance.PadRight(totalWidth)
public string PadRight (
    int totalWidth
)
public:
String^ PadRight (
    int totalWidth
)
public String PadRight (
    int totalWidth
)
public function PadRight (
    totalWidth : int
) : String

パラメータ

totalWidth

結果として生成される文字列文字数。これは、元の文字数と、埋め込み文字がある場合はその数を加えた数に等しくなります

戻り値
このインスタンス等価新しString。この新しインスタンスは文字左寄せされ、totalWidth長さになるまで右側空白埋め込まれています。または、totalWidth がこのインスタンス長さより短い場合は、このインスタンス等し新しString

例外例外
例外種類条件

ArgumentException

totalWidth が 0 未満です。

解説解説
使用例使用例

PadRight メソッドコード例次に示します

Dim str As String
str = "BBQ and Slaw"

Console.Write("|")
Console.Write(str.PadRight(15))
Console.WriteLine("|") ' Displays "|BBQ
 and Slaw   |".

Console.Write("|")
Console.Write(str.PadRight(5))
Console.WriteLine("|") ' Displays "|BBQ
 and Slaw|".
String^ str = "BBQ and Slaw";
Console::Write( "|" );
Console::Write( str->PadRight( 15 ) );
Console::WriteLine( "|" ); // Displays "|BBQ and Slaw
   |".
Console::Write( "|" );
Console::Write( str->PadRight( 5 ) );
Console::WriteLine( "|" ); // Displays "|BBQ and Slaw|".
var str : String;
str = "BBQ and Slaw";
Console.Write("|");
Console.Write(str.PadRight(15));
Console.WriteLine("|"); // Displays "|BBQ and Slaw  
 |".

Console.Write("|");
Console.Write(str.PadRight(5));
Console.WriteLine("|"); // Displays "|BBQ and Slaw|".
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.PadRight メソッド (Int32, Char)

この文字列文字左寄せし、指定した長さになるまで、指定した Unicode 文字右側埋め込みます。

名前空間: System
アセンブリ: mscorlib (mscorlib.dll 内)
構文構文

Public Function PadRight ( _
    totalWidth As Integer, _
    paddingChar As Char _
) As String
Dim instance As String
Dim totalWidth As Integer
Dim paddingChar As Char
Dim returnValue As String

returnValue = instance.PadRight(totalWidth, paddingChar)
public string PadRight (
    int totalWidth,
    char paddingChar
)
public:
String^ PadRight (
    int totalWidth, 
    wchar_t paddingChar
)
public String PadRight (
    int totalWidth, 
    char paddingChar
)
public function PadRight (
    totalWidth : int, 
    paddingChar : char
) : String

パラメータ

totalWidth

結果として生成される文字列文字数。これは、元の文字数と、埋め込み文字がある場合はその数を加えた数に等しくなります

paddingChar

Unicode 埋め込み文字

戻り値
このインスタンス等価新しString。この新しインスタンスは文字左寄せされ、totalWidth長さになるまで右側paddingChar文字埋め込まれています。または、totalWidth がこのインスタンス長さより短い場合は、このインスタンス等し新しString

例外例外
例外種類条件

ArgumentException

totalWidth が 0 未満です。

使用例使用例

PadRight メソッドコード例次に示します

Dim str As String
Dim pad As Char
str = "forty-two"
pad = Convert.ToChar(".") 
Console.WriteLine(str.PadRight(15, pad)) ' Displays "|forty-two......|".
Console.WriteLine(str.PadRight(2,  pad)) ' Displays "|forty-two|".
String^ str = "forty-two";
Console::Write( "|" );
Console::Write( str->PadRight( 15, '.' ) );
Console::WriteLine( "|" ); // Displays "|forty-two......|".
Console::Write( "|" );
Console::Write( str->PadRight( 5, '.' ) );
Console::WriteLine( "|" ); // Displays "|forty-two|".
var str : String = "forty-two";
var pad : char = ".";
Console.WriteLine(str.PadRight(15, pad)); // Displays "|forty-two......|".
Console.WriteLine(str.PadRight(2,  pad)); // Displays "|forty-two|".
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

String.PadRight メソッド



このページでは「.NET Framework クラス ライブラリ リファレンス」からString.PadRightを検索した結果を表示しています。
Weblioに収録されているすべての辞書からString.PadRightを検索する場合は、下記のリンクをクリックしてください。
 全ての辞書からString.PadRight を検索

英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「String.PadRight」の関連用語

String.PadRightのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



String.PadRightのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS