このメソッドを呼び出すと、必ず InvalidCastException がスローされます。
Overloads Public Shared Function ToChar( _
ByVal value As Decimal _) As Char
[C#]
public static char ToChar(decimalvalue);
[C++]
public: static __wchar_t ToChar(Decimalvalue);
[JScript]
public static function ToChar(
value : Decimal) : Char;
パラメータ
- value
Decimal の数値。
戻り値
この変換はサポートされていません。値は返されません。
例外
例外の種類 | 条件 |
---|---|
InvalidCastException | この変換はサポートされていません。 |
解説
このメソッドは、今後使用するために予約されています。
使用例
[Visual Basic, C#, C++] Decimal を Char に変換する際、エラー発生時に 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.ToChar オーバーロードの一覧