指定した 8 ビット符号なし整数値を、それと等価な Decimal の数値に変換します。
Overloads Public Shared Function ToDecimal( _
ByVal value As Byte _) As Decimal
[C#]
public static decimal ToDecimal(bytevalue);
[C++]
public: static Decimal ToDecimal(unsigned charvalue);
[JScript]
public static function ToDecimal(
value : Byte) : Decimal;
パラメータ
- value
8 ビット符号なし整数。
戻り値
value の値と等価な Decimal の数値。
使用例
[Visual Basic, C#, C++] ToDecimal を使用して、 Byte の値を Decimal の値に変換する方法については、次のコード例を参照してください。
Public Sub ConvertByteDecimal(ByVal byteVal As Byte)
Dim decimalVal As Decimal
' Byte to decimal conversion will not overflow.
decimalVal = System.Convert.ToDecimal(byteVal)
System.Console.WriteLine("The byte as a decimal is {0}.", _
decimalVal)
' Decimal to byte conversion can overflow.
Try
byteVal = System.Convert.ToByte(decimalVal)
System.Console.WriteLine("The Decimal as a byte is {0}.", _
byteVal)
Catch exception As System.OverflowException
System.Console.WriteLine( _
"Overflow in decimal-to-byte conversion.")
End Try
End Sub
[C#]
public void ConvertByteDecimal(byte byteVal) {
decimal decimalVal;
// Byte to decimal conversion will not overflow.
decimalVal = System.Convert.ToDecimal(byteVal);
System.Console.WriteLine("The byte as a decimal is {0}.",
decimalVal);
// Decimal to byte conversion can overflow.
try {
byteVal = System.Convert.ToByte(decimalVal);
System.Console.WriteLine("The Decimal as a byte is {0}.",
byteVal);
}
catch (System.OverflowException) {
System.Console.WriteLine(
"The decimal value is too large for a byte.");
}
}
[C++]
void ConvertByteDecimal(Byte byteVal)
{
Decimal decimalVal;
// Byte to decimal conversion will not overflow.
decimalVal = System::Convert::ToDecimal(byteVal);
System::Console::WriteLine(S"The Byte as a decimal is {0}.",
__box(decimalVal));
// Decimal to Byte conversion can overflow.
try {
byteVal = System::Convert::ToByte(decimalVal);
System::Console::WriteLine(S"The Decimal as a Byte is {0}.",
__box(byteVal));
} catch (System::OverflowException*) {
System::Console::WriteLine(S"The decimal value is too large for a Byte.");
}
}
[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.ToDecimal オーバーロードの一覧 | Decimal