次の方法で共有


Convert.ToDecimal メソッド (Char)

このメソッドを呼び出すと、必ず InvalidCastException がスローされます。

Overloads Public Shared Function ToDecimal( _
   ByVal value As Char _) As Decimal
[C#]
public static decimal ToDecimal(charvalue);
[C++]
public: static Decimal ToDecimal(__wchar_tvalue);
[JScript]
public static function ToDecimal(
   value : Char) : Decimal;

パラメータ

  • value
    Unicode 文字。

戻り値

この変換はサポートされていません。値は返されません。

例外

例外の種類 条件
InvalidCastException この変換はサポートされていません。

解説

このメソッドは、今後使用するために予約されています。

使用例

[Visual Basic, C#, C++] Char の値を Decimal に変換する際、エラー発生時に InvalidCastException をスローする方法については、次のコード例を参照してください。

 
Public Sub ConvertCharDecimal(ByVal charVal As Char)
    Dim decimalVal As [Decimal] = 0

    ' Char to decimal conversion is not supported and will always
    ' throw an InvalidCastException.
    Try
        decimalVal = System.Convert.ToDecimal(charVal)
    Catch exception As System.InvalidCastException
        System.Console.WriteLine( _
             "Char-to-decimal conversion is not supported " + _
             "by the framework.")
    End Try

    'Decimal to char conversion is also not supported.
    Try
        charVal = System.Convert.ToChar(decimalVal)
    Catch exception As System.InvalidCastException
        System.Console.WriteLine( _
            "Decimal-to-char conversion is not supported " + _
            "by the framework.")
    End Try
End Sub

[C#] 
public void ConvertCharDecimal(char charVal) {
    Decimal decimalVal = 0;
    
    // Char to decimal conversion is not supported and will always
    // throw an InvalidCastException.
    try {
        decimalVal = System.Convert.ToDecimal(charVal);
    } 
    catch (System.InvalidCastException) {
        System.Console.WriteLine(
            "Char-to-decimal conversion is not supported " +
            "by the framework.");
    }

    //Decimal to char conversion is also not supported.
    try {
        charVal = System.Convert.ToChar(decimalVal);
    } 
    catch (System.InvalidCastException) {
        System.Console.WriteLine(
            "Decimal-to-char conversion is not supported " +
            "by the framework.");
    }
}

[C++] 

   void ConvertCharDecimal(Char charVal)
   {
      Decimal decimalVal = 0;

      // Char to decimal conversion is not supported and will always
      // throw an InvalidCastException.
      try {
         decimalVal = System::Convert::ToDecimal(charVal);
      } catch (System::InvalidCastException*) {
         System::Console::WriteLine(S"Char-to-decimal conversion is not supported by the framework.");
      }

      //Decimal to char conversion is also not supported.
      try {
         charVal = System::Convert::ToChar(decimalVal);
      } catch (System::InvalidCastException*) {
         System::Console::WriteLine(S"Decimal-to-char conversion is not supported by the framework.");
      }
   }

[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

参照

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