C# Convert ToSByte(Decimal)

Description

Convert ToSByte(Decimal) converts the value of the specified decimal number to an equivalent 8-bit signed integer.

Syntax

Convert.ToSByte(Decimal) has the following syntax.


[CLSCompliantAttribute(false)]
public static sbyte ToSByte(
  decimal value
)

Parameters

Convert.ToSByte(Decimal) has the following parameters.

  • value - The decimal number to convert.

Returns

Convert.ToSByte(Decimal) method returns value, rounded to the nearest 8-bit signed integer. If value is halfway between two whole numbers, the even number is returned; that is, 4.5 is converted to 4, and 5.5 is converted to 6.

Example


/* w w  w. j ava 2 s  . c  om*/
using System;
public class MainClass{
  public static void Main(String[] argv){  
    Console.WriteLine(Convert.ToSByte(123.123M));
  }
}
    

The code above generates the following result.





















Home »
  C# Tutorial »
    System »




Array
BitConverter
Boolean
Byte
Char
Console
ConsoleKeyInfo
Convert
DateTime
DateTimeOffset
Decimal
Double
Enum
Environment
Exception
Guid
Int16
Int32
Int64
Math
OperatingSystem
Random
SByte
Single
String
StringComparer
TimeSpan
TimeZone
TimeZoneInfo
Tuple
Tuple
Tuple
Type
UInt16
UInt32
UInt64
Uri
Version