IFormattable.ToString メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Dim instance As IFormattable Dim format As String Dim formatProvider As IFormatProvider Dim returnValue As String returnValue = instance.ToString(format, formatProvider)
戻り値
指定した書式で現在のインスタンスの値が格納されている String。

NumberFormatInfo、DateTimeFormatInfo、および CultureInfo は IFormatProvider インターフェイスを実装します。
NumberFormatInfo は、桁区切り記号に使用される文字や、金額値の通貨記号のスペルと位置など、数値書式情報を指定します。
DateTimeFormatInfo は、日付パターンでの年月日の位置など、日付と時刻に関連する書式情報を指定します。
CultureInfo には、特定のカルチャの既定の書式情報が含まれています。このような情報には、数値の書式情報や日付と時刻の書式情報などがあります。

ToString メソッドを実装するコード例を次に示します。このコード例は、IFormattable クラスのトピックで取り上げているコード例の一部分です。
public override String ToString() { return ToString(null, null); } public String ToString(String format, IFormatProvider fp) { // If no format is passed, display like this: (x, y). if (format == null) return String.Format("({0}, {1})", x, y); // For "x" formatting, return just the x value as a string if (format == "x") return x.ToString(); // For "y" formatting, return just the y value as a string if (format == "y") return y.ToString(); // For any unrecognized format, throw an exception. throw new FormatException(String.Format("Invalid format string: '{0}'.", format)); }
public: virtual String^ ToString() override { return ToString(nullptr, nullptr); } public: virtual String^ ToString(String^ format, IFormatProvider^ formatProvider) { // If no format is passed, display like this: (x, y). if (format == nullptr) { return String::Format("({0}, {1})", x, y); } // For "x" formatting, return just the x value as a string if (format == "x") { return x.ToString(); } // For "y" formatting, return just the y value as a string if (format == "y") { return y.ToString(); } // For any unrecognized format, throw an exception. throw gcnew FormatException(String::Format( "Invalid format string: '{0}'.", format)); }

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からIFormattable.ToString メソッドを検索する場合は、下記のリンクをクリックしてください。

- IFormattable.ToString メソッドのページへのリンク