次の方法で共有


Convert.ToString メソッド (Double)

指定した倍精度浮動小数点数値を、それと等価な String 形式に変換します。

Overloads Public Shared Function ToString( _
   ByVal value As Double _) As String
[C#]
public static string ToString(doublevalue);
[C++]
public: static String* ToString(doublevalue);
[JScript]
public static function ToString(
   value : double) : String;

パラメータ

  • value
    倍精度浮動小数点数。

戻り値

value の値と等価な String

解説

この実装は、 Double.ToString と同じです。

使用例

[Visual Basic, C#, C++] ToString を使用して、 DoubleString に変換する方法については、次のコード例を参照してください。

 
Public Sub ConvertDoubleString(ByVal doubleVal As Double)

    Dim stringVal As String

    ' A conversion from Double to String cannot overflow.       
    stringVal = System.Convert.ToString(doubleVal)
    System.Console.WriteLine("{0} as a String is: {1}", _
                              doubleVal, stringVal)

    Try
        doubleVal = System.Convert.ToDouble(stringVal)
        System.Console.WriteLine("{0} as a Double is: {1}", _
                                  stringVal, doubleVal)
    Catch exception As System.OverflowException
        System.Console.WriteLine( _
            "Overflow in String-to-Double conversion.")
    Catch exception As System.FormatException
        System.Console.WriteLine( _
            "The string is not formatted as a Double.")
    Catch exception As System.ArgumentException
        System.Console.WriteLine("The string is null.")
    End Try

End Sub

[C#] 
public void ConvertDoubleString(double doubleVal) {
    
    string    stringVal;     

    // A conversion from Double to string cannot overflow.       
    stringVal = System.Convert.ToString(doubleVal);
    System.Console.WriteLine("{0} as a string is: {1}",
        doubleVal, stringVal);

    try {
        doubleVal = System.Convert.ToDouble(stringVal);
        System.Console.WriteLine("{0} as a double is: {1}",
            stringVal, doubleVal);
    } 
    catch (System.OverflowException) {
        System.Console.WriteLine(
            "Conversion from string-to-double overflowed.");
    }
    catch (System.FormatException) {
        System.Console.WriteLine(
            "The string was not formatted as a double.");
    }
    catch (System.ArgumentException) {
        System.Console.WriteLine(
            "The string pointed to null.");
    }
}

[C++] 

   void ConvertDoubleString(double doubleVal)
   {
      String*    stringVal;     

      // A conversion from Double to String* cannot overflow.       
      stringVal = System::Convert::ToString(doubleVal);
      System::Console::WriteLine(S" {0} as a String* is: {1}",
         __box(doubleVal), stringVal);

      try {
         doubleVal = System::Convert::ToDouble(stringVal);
         System::Console::WriteLine(S" {0} as a double is: {1}",
            stringVal, __box(doubleVal));
      } catch (System::OverflowException*) {
         System::Console::WriteLine(S"Conversion from String*-to-double overflowed.");
      } catch (System::FormatException*) {
         System::Console::WriteLine(S"The String* was not formatted as a double.");
      } catch (System::ArgumentException*) {
         System::Console::WriteLine(S"The String* pointed to null.");
      }
   }

[JScript] JScript のサンプルはありません。Visual Basic、C#、および C++ のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン 言語のフィルタ をクリックします。

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ, .NET Compact Framework - Windows CE .NET, Common Language Infrastructure (CLI) Standard

参照

Convert クラス | Convert メンバ | System 名前空間 | Convert.ToString オーバーロードの一覧