Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
Convert.ToSByte Method in C#
Convert a specified value to an 8-bit signed integer i.e. SByte.
It is a signed 8-bit integer data type which stores value between -128 to 127.
Let us see an example. We have a double variable.
double doubleNum = -19.9;
Now, let us convert it to SByte.
sbyte res; res = Convert.ToSByte(doubleNum);
Example
using System;
public class Demo {
public static void Main() {
double doubleNum = -19.9;
sbyte res;
res = Convert.ToSByte(doubleNum);
Console.WriteLine("Converted {0} to {1}", doubleNum, res);
}
}
Output
Converted -19.9 to -20
Advertisements
