Convert various data types to integer 64
using System;
class Sample
{
public static void Main()
{
bool xBool = false;
short xShort = 1;
int xInt = 2;
long xLong = 3;
float xSingle = 4.0f;
double xDouble = 5.0;
decimal xDecimal = 6.0m;
string xString = "7";
char xChar = '8';
byte xByte = 9;
ushort xUshort = 120;
uint xUint = 121;
ulong xUlong = 122;
sbyte xSbyte = 123;
Console.WriteLine("Boolean: {0}", Convert.ToInt64(xBool));
Console.WriteLine("Int16: {0}", Convert.ToInt64(xShort));
Console.WriteLine("Int32: {0}", Convert.ToInt64(xInt));
Console.WriteLine("Int64: {0}", Convert.ToInt64(xLong));
Console.WriteLine("Single: {0}", Convert.ToInt64(xSingle));
Console.WriteLine("Double: {0}", Convert.ToInt64(xDouble));
Console.WriteLine("Decimal: {0}", Convert.ToInt64(xDecimal));
Console.WriteLine("String: {0}", Convert.ToInt64(xString));
Console.WriteLine("Char: {0}", Convert.ToInt64(xChar));
Console.WriteLine("Byte: {0}", Convert.ToInt64(xByte));
Console.WriteLine("UInt16: {0}", Convert.ToInt64(xUshort));
Console.WriteLine("UInt32: {0}", Convert.ToInt64(xUint));
Console.WriteLine("UInt64: {0}", Convert.ToInt64(xUlong));
Console.WriteLine("SByte: {0}", Convert.ToInt64(xSbyte));
}
}
Related examples in the same category