SByte.ToString メソッド

定義

このインスタンスの数値を、それと等価な文字列形式に変換します。

オーバーロード

ToString()

このインスタンスの数値を、それと等価な文字列形式に変換します。

ToString(IFormatProvider)

このインスタンスの数値を、指定したカルチャ固有の書式情報を使用して、それと等価な文字列形式に変換します。

ToString(String)

指定した書式を使用して、このインスタンスの数値を、それと等価な文字列形式に変換します。

ToString(String, IFormatProvider)

このインスタンスの数値を、指定した書式およびカルチャ固有の書式情報を使用して、それと等価な文字列形式に変換します。

ToString()

このインスタンスの数値を、それと等価な文字列形式に変換します。

public:
 override System::String ^ ToString();
public override string ToString ();
override this.ToString : unit -> string
Public Overrides Function ToString () As String

戻り値

値が負の場合はマイナス記号を伴い、先行ゼロを含まない 0 から 9 の一連の数字から構成される、このインスタンスの値の文字列形式。

次の例では、既定ToString()のメソッドをSByte使用して値を表示します。 また、多数の標準書式指定子を SByte 使用した結果の値の文字列表現も表示されます。 例は、en-US カルチャの書式設定規則を使用して表示されます。

using System;

public class Example
{
   public static void Main()
   {
      sbyte value = -123;
      // Display value using default ToString method.
      Console.WriteLine(value.ToString());            // Displays -123
      // Display value using some standard format specifiers.
      Console.WriteLine(value.ToString("G"));         // Displays -123
      Console.WriteLine(value.ToString("C"));         // Displays ($-123.00)
      Console.WriteLine(value.ToString("D"));         // Displays -123
      Console.WriteLine(value.ToString("F"));         // Displays -123.00
      Console.WriteLine(value.ToString("N"));         // Displays -123.00
      Console.WriteLine(value.ToString("X"));         // Displays 85
   }
}
let value = -123y
// Display value using default ToString method.
printfn $"{value.ToString()}"               // Displays -123
// Display value using some standard format specifiers.
printfn $"""{value.ToString "G"}"""         // Displays -123
printfn $"""{value.ToString "C"}"""         // Displays ($-123.00)
printfn $"""{value.ToString "D"}"""         // Displays -123
printfn $"""{value.ToString "F"}"""         // Displays -123.00
printfn $"""{value.ToString "N"}"""         // Displays -123.00
printfn $"""{value.ToString "X"}"""         // Displays 85
Module Example
   Public Sub Main()
      Dim value As SByte = -123
      ' Display value using default ToString method.
      Console.WriteLine(value.ToString())            ' Displays -123
      ' Display value using some standard format specifiers.
      Console.WriteLine(value.ToString("G"))         ' Displays -123
      Console.WriteLine(value.ToString("C"))         ' Displays ($-123.00)
      Console.WriteLine(value.ToString("D"))         ' Displays -123
      Console.WriteLine(value.ToString("F"))         ' Displays -123.00
      Console.WriteLine(value.ToString("N"))         ' Displays -123.00
      Console.WriteLine(value.ToString("X"))         ' Displays 85
   End Sub
End Module

注釈

メソッドは ToString() 、現在の SByte カルチャの既定の ("G"、または一般的な) 形式で値を書式設定します。 別の形式またはカルチャを指定する場合は、次のように メソッドの他のオーバーロードを ToString 使用します。

書式を使用するには カルチャの場合 オーバーロードを使用する
既定 ("G") 形式 特定のカルチャ ToString(IFormatProvider)
特定の形式 既定の (現在の) カルチャ ToString(String)
特定の形式 特定のカルチャ ToString(String, IFormatProvider)

戻り値は、一般的な数値書式指定子 ("G") を使用して書式設定されます。値の文字列表現には負の符号 (負の SByte 値の場合) と、先頭にゼロを付けずに 0 から 9 までの数字のシーケンスが含まれます。 負の符号は、現在のカルチャの NumberFormatInfo オブジェクトによって定義されます。

符号付きバイト値の文字列表現の書式を定義するには、 メソッドを ToString(String) 呼び出します。

こちらもご覧ください

適用対象

ToString(IFormatProvider)

このインスタンスの数値を、指定したカルチャ固有の書式情報を使用して、それと等価な文字列形式に変換します。

public:
 virtual System::String ^ ToString(IFormatProvider ^ provider);
public:
 System::String ^ ToString(IFormatProvider ^ provider);
public string ToString (IFormatProvider provider);
public string ToString (IFormatProvider? provider);
override this.ToString : IFormatProvider -> string
Public Function ToString (provider As IFormatProvider) As String

パラメーター

provider
IFormatProvider

カルチャ固有の書式情報を提供するオブジェクト。

戻り値

provider で指定された、このインスタンスの値の文字列形式。

実装

次の例では、カスタム NumberFormatInfo オブジェクトを定義し、その NegativeSign プロパティに "~" 文字を割り当てます。 次に、このカスタム オブジェクトとインバリアント カルチャの オブジェクトを NumberFormatInfo 使用して、一連の値を SByte 書式設定します。

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      // Define a custom NumberFormatInfo object with "~" as its negative sign.
      NumberFormatInfo nfi = new NumberFormatInfo();
      nfi.NegativeSign = "~";
      
      // Initialize an array of SByte values.
      sbyte[] bytes = { -122, 17, 124 };

      // Display the formatted result using the custom provider.
      Console.WriteLine("Using the custom NumberFormatInfo object:");
      foreach (sbyte value in bytes)
         Console.WriteLine(value.ToString(nfi));

      Console.WriteLine();
          
      // Display the formatted result using the invariant culture.
      Console.WriteLine("Using the invariant culture:");
      foreach (sbyte value in bytes)
         Console.WriteLine(value.ToString(NumberFormatInfo.InvariantInfo));
   }
}
// The example displays the following output:
//       Using the custom NumberFormatInfo object:
//       ~122
//       17
//       124
//       
//       Using the invariant culture:
//       -122
//       17
//       124
open System.Globalization

// Define a custom NumberFormatInfo object with "~" as its negative sign.
let nfi = NumberFormatInfo(NegativeSign = "~")

// Initialize an array of SByte values.
let bytes = [| -122y; 17y; 124y |]

// Display the formatted result using the custom provider.
printfn "Using the custom NumberFormatInfo object:"
for value in bytes do
    printfn $"{value.ToString nfi}"

printfn ""
      
// Display the formatted result using the invariant culture.
printfn "Using the invariant culture:"
for value in bytes do
   printfn $"{value.ToString NumberFormatInfo.InvariantInfo}"
// The example displays the following output:
//       Using the custom NumberFormatInfo object:
//       ~122
//       17
//       124
//       
//       Using the invariant culture:
//       -122
//       17
//       124
Imports System.Globalization

Module Example
   Public Sub Main()
      ' Define a custom NumberFormatInfo object with "~" as its negative sign.
      Dim nfi As New NumberFormatInfo()
      nfi.NegativeSign = "~"
      
      ' Initialize an array of SByte values.
      Dim bytes() As SByte = { -122, 17, 124 }

      ' Display the formatted result using the custom provider.
      Console.WriteLine("Using the custom NumberFormatInfo object:")
      For Each value As SByte In bytes
         Console.WriteLine(value.ToString(nfi))
      Next
      Console.WriteLine()
          
      ' Display the formatted result using the invariant culture.
      Console.WriteLine("Using the invariant culture:")
      For Each value As SByte In bytes
         Console.WriteLine(value.ToString(NumberFormatInfo.InvariantInfo))
      Next   
   End Sub
End Module
' The example displays the following output:
'       Using the custom NumberFormatInfo object:
'       ~122
'       17
'       124
'       
'       Using the invariant culture:
'       -122
'       17
'       124

注釈

メソッドは ToString(IFormatProvider)SByte 指定されたカルチャの既定の ("G"、または一般的な) 形式で値を書式設定します。 別の形式または現在のカルチャを指定する場合は、次のように メソッドの他のオーバーロードを ToString 使用します。

書式を使用するには カルチャの場合 オーバーロードを使用する
既定 ("G") 形式 既定の (現在の) カルチャ ToString()
特定の形式 既定の (現在の) カルチャ ToString(String)
特定の形式 特定のカルチャ ToString(String, IFormatProvider)

パラメーターは provider 実装です IFormatProvider 。 そのメソッドは GetFormatNumberFormatInfo このメソッドによって返される文字列の形式に関するカルチャ固有の情報を提供する オブジェクトを返します。 が nullの場合providerSByte値は現在のカルチャの オブジェクトをNumberFormatInfo使用して書式設定されます。 一般的な書式指定子を NumberFormatInfo 使用して値の文字列表現を SByte 制御するオブジェクトの唯一のプロパティは です NumberFormatInfo.NegativeSign。これは、負の符号を表す文字を定義します。

パラメーターには provider 、次のいずれかを指定できます。

  • CultureInfo書式設定情報を提供するカルチャを表す オブジェクト。

  • NumberFormatInfo書式設定情報を提供する オブジェクト。

  • を実装 IFormatProviderするカスタム オブジェクト。 そのメソッドは GetFormat 、書式設定情報を NumberFormatInfo 提供する オブジェクトを返します。

こちらもご覧ください

適用対象

ToString(String)

指定した書式を使用して、このインスタンスの数値を、それと等価な文字列形式に変換します。

public:
 System::String ^ ToString(System::String ^ format);
public string ToString (string format);
public string ToString (string? format);
override this.ToString : string -> string
Public Function ToString (format As String) As String

パラメーター

format
String

標準またはカスタムの数値書式指定文字列。

戻り値

format で指定された、このインスタンスの値の文字列形式。

例外

format が無効です。

次の例では、値の SByte 配列を初期化し、各標準書式指定文字列といくつかのカスタム書式指定文字列を使用して表示します。

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      sbyte[] values = { -124, 0, 118 };
      string[] specifiers = { "G", "C", "D3", "E2", "e3", "F", 
                              "N", "P", "X", "00.0", "#.0", 
                              "000;(0);**Zero**" };
      
      foreach (sbyte value in values)
      {
         foreach (string specifier in specifiers)
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier));
         Console.WriteLine();
      }
   }
}
// The example displays the following output:
//       G: -124
//       C: ($124.00)
//       D3: -124
//       E2: -1.24E+002
//       e3: -1.240e+002
//       F: -124.00
//       N: -124.00
//       P: -12,400.00 %
//       X: 84
//       00.0: -124.0
//       #.0: -124.0
//       000;(0);**Zero**: (124)
//       
//       G: 0
//       C: $0.00
//       D3: 000
//       E2: 0.00E+000
//       e3: 0.000e+000
//       F: 0.00
//       N: 0.00
//       P: 0.00 %
//       X: 0
//       00.0: 00.0
//       #.0: .0
//       000;(0);**Zero**: **Zero**
//       
//       G: 118
//       C: $118.00
//       D3: 118
//       E2: 1.18E+002
//       e3: 1.180e+002
//       F: 118.00
//       N: 118.00
//       P: 11,800.00 %
//       X: 76
//       00.0: 118.0
//       #.0: 118.0
//       000;(0);**Zero**: 118
let values = [| -124y; 0y; 118y |]
let specifiers = 
    [| "G"; "C"; "D3"; "E2"; "e3"; "F" 
       "N"; "P"; "X"; "00.0"; "#.0" 
       "000(0)**Zero**" |]

for value in values do
    for specifier in specifiers do
        printfn $"{specifier}: {value.ToString specifier}"
    printfn ""
// The example displays the following output:
//       G: -124
//       C: ($124.00)
//       D3: -124
//       E2: -1.24E+002
//       e3: -1.240e+002
//       F: -124.00
//       N: -124.00
//       P: -12,400.00 %
//       X: 84
//       00.0: -124.0
//       #.0: -124.0
//       000(0)**Zero**: (124)
//       
//       G: 0
//       C: $0.00
//       D3: 000
//       E2: 0.00E+000
//       e3: 0.000e+000
//       F: 0.00
//       N: 0.00
//       P: 0.00 %
//       X: 0
//       00.0: 00.0
//       #.0: .0
//       000(0)**Zero**: **Zero**
//       
//       G: 118
//       C: $118.00
//       D3: 118
//       E2: 1.18E+002
//       e3: 1.180e+002
//       F: 118.00
//       N: 118.00
//       P: 11,800.00 %
//       X: 76
//       00.0: 118.0
//       #.0: 118.0
//       000(0)**Zero**: 118
Imports System.Globalization

Module Example
   Public Sub Main()
      Dim values() As SByte = { -124, 0, 118 }
      Dim specifiers() As String = { "G", "C", "D3", "E2", "e3", "F", _
                                     "N", "P", "X", "00.0", "#.0", _
                                     "000;(0);**Zero**" }
      
      For Each value As SByte In values
         For Each specifier As String In specifiers
            Console.WriteLine("{0}: {1}", specifier, value.ToString(specifier))
         Next
         Console.WriteLine()
      Next
   End Sub
End Module
' The example displays the following output:
'       G: -124
'       C: ($124.00)
'       D3: -124
'       E2: -1.24E+002
'       e3: -1.240e+002
'       F: -124.00
'       N: -124.00
'       P: -12,400.00 %
'       X: 84
'       00.0: -124.0
'       #.0: -124.0
'       000;(0);**Zero**: (124)
'       
'       G: 0
'       C: $0.00
'       D3: 000
'       E2: 0.00E+000
'       e3: 0.000e+000
'       F: 0.00
'       N: 0.00
'       P: 0.00 %
'       X: 0
'       00.0: 00.0
'       #.0: .0
'       000;(0);**Zero**: **Zero**
'       
'       G: 118
'       C: $118.00
'       D3: 118
'       E2: 1.18E+002
'       e3: 1.180e+002
'       F: 118.00
'       N: 118.00
'       P: 11,800.00 %
'       X: 76
'       00.0: 118.0
'       #.0: 118.0
'       000;(0);**Zero**: 118

注釈

メソッドは ToString(String) 、現在の SByte カルチャの規則を使用して、指定した形式で値を書式設定します。 既定の ("G"、または一般的な) 形式を使用する場合、または別のカルチャを指定する場合は、次のように メソッドの他のオーバーロードを ToString 使用します。

書式を使用するには カルチャの場合 オーバーロードを使用する
既定 ("G") 形式 既定の (現在の) カルチャ ToString()
既定 ("G") 形式 特定のカルチャ ToString(IFormatProvider)
特定の形式 特定のカルチャ ToString(String, IFormatProvider)

パラメーターには format 、任意の有効な標準数値書式指定子、またはカスタム数値書式指定子の任意の組み合わせを指定できます。 が String.Empty または の場合formatnull現在SByteのオブジェクトの戻り値は一般的な書式指定子 ("G") で書式設定されます。 が他の値である場合 format 、メソッドは を FormatExceptionスローします。

.NET では、広範な書式設定のサポートが提供されています。詳細については、次の書式設定に関するトピックを参照してください。

返される文字列の形式は、現在のカルチャの NumberFormatInfo オブジェクトによって決まります。 パラメーターに format 応じて、このオブジェクトは、負符号、グループ区切り記号、出力文字列の小数点記号などの記号を制御します。 現在のカルチャ以外のカルチャの書式設定情報を提供するには、 オーバーロードを ToString(String, IFormatProvider) 呼び出します。

こちらもご覧ください

適用対象

ToString(String, IFormatProvider)

このインスタンスの数値を、指定した書式およびカルチャ固有の書式情報を使用して、それと等価な文字列形式に変換します。

public:
 virtual System::String ^ ToString(System::String ^ format, IFormatProvider ^ provider);
public string ToString (string format, IFormatProvider provider);
public string ToString (string? format, IFormatProvider? provider);
override this.ToString : string * IFormatProvider -> string
Public Function ToString (format As String, provider As IFormatProvider) As String

パラメーター

format
String

標準またはカスタムの数値書式指定文字列。

provider
IFormatProvider

カルチャ固有の書式情報を提供するオブジェクト。

戻り値

format および provider で指定された、このインスタンスの値の文字列形式。

実装

例外

format が無効です。

次の例では、標準の数値書式指定子と特定CultureInfoのオブジェクトの数を使用して、正と負SByteの両方の値を表示します。

using System;
using System.Globalization;

public class Example
{
   public static void Main()
   {
      // Define cultures whose formatting conventions are to be used.
      CultureInfo[] cultures = { CultureInfo.CreateSpecificCulture("en-US"), 
                                 CultureInfo.CreateSpecificCulture("fr-FR"), 
                                 CultureInfo.CreateSpecificCulture("es-ES") };
      sbyte positiveNumber = 119;
      sbyte negativeNumber = -45;
      string[] specifiers = {"G", "C", "D4", "E2", "F", "N", "P", "X2"}; 
      
      foreach (string specifier in specifiers)
      {
         foreach (CultureInfo culture in cultures)
            Console.WriteLine("{0,2} format using {1} culture: {2, 16} {3, 16}",  
                              specifier, culture.Name, 
                              positiveNumber.ToString(specifier, culture), 
                              negativeNumber.ToString(specifier, culture));
         Console.WriteLine();
      }
   }
}
// The example displays the following output:
//     G format using en-US culture:              119              -45
//     G format using fr-FR culture:              119              -45
//     G format using es-ES culture:              119              -45
//    
//     C format using en-US culture:          $119.00         ($45.00)
//     C format using fr-FR culture:         119,00 €         -45,00 €
//     C format using es-ES culture:         119,00 €         -45,00 €
//    
//    D4 format using en-US culture:             0119            -0045
//    D4 format using fr-FR culture:             0119            -0045
//    D4 format using es-ES culture:             0119            -0045
//    
//    E2 format using en-US culture:        1.19E+002       -4.50E+001
//    E2 format using fr-FR culture:        1,19E+002       -4,50E+001
//    E2 format using es-ES culture:        1,19E+002       -4,50E+001
//    
//     F format using en-US culture:           119.00           -45.00
//     F format using fr-FR culture:           119,00           -45,00
//     F format using es-ES culture:           119,00           -45,00
//    
//     N format using en-US culture:           119.00           -45.00
//     N format using fr-FR culture:           119,00           -45,00
//     N format using es-ES culture:           119,00           -45,00
//    
//     P format using en-US culture:      11,900.00 %      -4,500.00 %
//     P format using fr-FR culture:      11 900,00 %      -4 500,00 %
//     P format using es-ES culture:      11.900,00 %      -4.500,00 %
//    
//    X2 format using en-US culture:               77               D3
//    X2 format using fr-FR culture:               77               D3
//    X2 format using es-ES culture:               77               D3
open System.Globalization

// Define cultures whose formatting conventions are to be used.
let cultures = 
    [| CultureInfo.CreateSpecificCulture "en-US" 
       CultureInfo.CreateSpecificCulture "fr-FR" 
       CultureInfo.CreateSpecificCulture "es-ES" |]
let positiveNumber = 119y
let negativeNumber = -45y
let specifiers = [| "G"; "C"; "D4"; "E2"; "F"; "N"; "P"; "X2" |]

for specifier in specifiers do
    for culture in cultures do
        printfn $"{specifier,2} format using {culture.Name} culture: {positiveNumber.ToString(specifier, culture), 16} {negativeNumber.ToString(specifier, culture), 16}"
    printfn ""
// The example displays the following output:
//     G format using en-US culture:              119              -45
//     G format using fr-FR culture:              119              -45
//     G format using es-ES culture:              119              -45
//    
//     C format using en-US culture:          $119.00         ($45.00)
//     C format using fr-FR culture:         119,00 €         -45,00 €
//     C format using es-ES culture:         119,00 €         -45,00 €
//    
//    D4 format using en-US culture:             0119            -0045
//    D4 format using fr-FR culture:             0119            -0045
//    D4 format using es-ES culture:             0119            -0045
//    
//    E2 format using en-US culture:        1.19E+002       -4.50E+001
//    E2 format using fr-FR culture:        1,19E+002       -4,50E+001
//    E2 format using es-ES culture:        1,19E+002       -4,50E+001
//    
//     F format using en-US culture:           119.00           -45.00
//     F format using fr-FR culture:           119,00           -45,00
//     F format using es-ES culture:           119,00           -45,00
//    
//     N format using en-US culture:           119.00           -45.00
//     N format using fr-FR culture:           119,00           -45,00
//     N format using es-ES culture:           119,00           -45,00
//    
//     P format using en-US culture:      11,900.00 %      -4,500.00 %
//     P format using fr-FR culture:      11 900,00 %      -4 500,00 %
//     P format using es-ES culture:      11.900,00 %      -4.500,00 %
//    
//    X2 format using en-US culture:               77               D3
//    X2 format using fr-FR culture:               77               D3
//    X2 format using es-ES culture:               77               D3
Imports System.Globalization

Module Example
   Public Sub Main()
      ' Define cultures whose formatting conventions are to be used.
      Dim cultures() As CultureInfo = {CultureInfo.CreateSpecificCulture("en-US"), _
                                       CultureInfo.CreateSpecificCulture("fr-FR"), _
                                       CultureInfo.CreateSpecificCulture("es-ES") }
      Dim positiveNumber As SByte = 119
      Dim negativeNumber As SByte = -45
      Dim specifiers() As String = {"G", "C", "D4", "E2", "F", "N", "P", "X2"} 
      
      For Each specifier As String In specifiers
         For Each culture As CultureInfo In Cultures
            Console.WriteLine("{0,2} format using {1} culture: {2, 16} {3, 16}", _ 
                              specifier, culture.Name, _
                              positiveNumber.ToString(specifier, culture), _
                              negativeNumber.ToString(specifier, culture))

         Next
         Console.WriteLine()
      Next
   End Sub
End Module
' The example displays the following output:
'     G format using en-US culture:              119              -45
'     G format using fr-FR culture:              119              -45
'     G format using es-ES culture:              119              -45
'    
'     C format using en-US culture:          $119.00         ($45.00)
'     C format using fr-FR culture:         119,00 €         -45,00 €
'     C format using es-ES culture:         119,00 €         -45,00 €
'    
'    D4 format using en-US culture:             0119            -0045
'    D4 format using fr-FR culture:             0119            -0045
'    D4 format using es-ES culture:             0119            -0045
'    
'    E2 format using en-US culture:        1.19E+002       -4.50E+001
'    E2 format using fr-FR culture:        1,19E+002       -4,50E+001
'    E2 format using es-ES culture:        1,19E+002       -4,50E+001
'    
'     F format using en-US culture:           119.00           -45.00
'     F format using fr-FR culture:           119,00           -45,00
'     F format using es-ES culture:           119,00           -45,00
'    
'     N format using en-US culture:           119.00           -45.00
'     N format using fr-FR culture:           119,00           -45,00
'     N format using es-ES culture:           119,00           -45,00
'    
'     P format using en-US culture:      11,900.00 %      -4,500.00 %
'     P format using fr-FR culture:      11 900,00 %      -4 500,00 %
'     P format using es-ES culture:      11.900,00 %      -4.500,00 %
'    
'    X2 format using en-US culture:               77               D3
'    X2 format using fr-FR culture:               77               D3
'    X2 format using es-ES culture:               77               D3

注釈

メソッドは ToString(String, IFormatProvider) 、指定した SByte カルチャの指定した形式で値を書式設定します。 既定の形式またはカルチャ設定を使用する場合は、次のように メソッドの他のオーバーロードを ToString 使用します。

書式を使用するには カルチャの場合 オーバーロードを使用する
既定 ("G") 形式 既定の (現在の) カルチャ ToString()
既定の ("G") 形式 特定のカルチャ ToString(IFormatProvider)
特定の形式 既定の (現在の) カルチャ ToString(String)

パラメーターには format 、任意の有効な標準数値書式指定子、またはカスタム数値書式指定子の任意の組み合わせを指定できます。 が または nullString.Empty場合format、現在SByteのオブジェクトの戻り値は、一般的な書式指定子 ("G") で書式設定されます。 が他の値の場合 format 、 メソッドは を FormatExceptionスローします。

.NET では、以下の書式設定に関するトピックで詳しく説明されている広範な書式設定のサポートが提供されています。

パラメーターは provider 実装です IFormatProvider 。 そのメソッドは GetFormatNumberFormatInfo このメソッドによって返される文字列の形式に関するカルチャ固有の情報を提供する オブジェクトを返します。 メソッドがToString(String, IFormatProvider)呼び出されると、パラメーターの IFormatProvider.GetFormat メソッドがprovider呼び出され、型をType表すオブジェクトがNumberFormatInfo渡されます。 次に、 メソッドはGetFormat、負符号記号、グループ区切り記号、小数点記号など、パラメーターの書式設定valueに関する情報を提供する オブジェクトを返NumberFormatInfoします。 パラメーターを使用してメソッドに provider 書式設定情報を指定するには、次の ToString(String, IFormatProvider) 3 つの方法があります。

  • 書式設定情報を CultureInfo 提供するカルチャを表す オブジェクトを渡すことができます。 そのメソッドは GetFormat 、そのカルチャの NumberFormatInfo 数値書式情報を提供する オブジェクトを返します。

  • 数値書式情報を提供する実際 NumberFormatInfo のオブジェクトを渡すことができます。 (の実装 GetFormat はそれ自体を返すだけです)。

  • を実装 IFormatProviderするカスタム オブジェクトを渡すことができます。 そのメソッドは GetFormat 、書式設定情報を提供する オブジェクトを NumberFormatInfo インスタンス化して返します。

nullの場合provider、返される文字列の書式設定は、現在のNumberFormatInfoカルチャのオブジェクトに基づきます。

こちらもご覧ください

適用対象