Int64
C#
sbyte value1 = 124;
short value2 = 1618;
int value3 = Int32.MaxValue;
long number1 = value1;
long number2 = value2;
long number3 = value3;
decimal[] values= { Decimal.MinValue, -1034.23m, -12m, 0m, 147m,
199.55m, 9214.16m, Decimal.MaxValue };
long result;
foreach (decimal value in values)
{
try {
result = Convert.ToInt64(value);
Console.WriteLine("Converted the {0} value '{1}' to the {2} value {3}.",
value.GetType().Name, value,
result.GetType().Name, result);
}
catch (OverflowException) {
Console.WriteLine("{0} is outside the range of the Int64 type.",
value);
}
}
// The example displays the following output:
// -79228162514264337593543950335 is outside the range of the Int64 type.
// Converted the Decimal value '-1034.23' to the Int64 value -1034.
// Converted the Decimal value '-12' to the Int64 value -12.
// Converted the Decimal value '0' to the Int64 value 0.
// Converted the Decimal value '147' to the Int64 value 147.
// Converted the Decimal value '199.55' to the Int64 value 200.
// Converted the Decimal value '9214.16' to the Int64 value 9214.
// 79228162514264337593543950335 is outside the range of the Int64 type.
ulong ulNumber = 163245617943825;
try {
long number1 = (long) ulNumber;
Console.WriteLine(number1);
}
catch (OverflowException) {
Console.WriteLine("{0} is out of range of an Int64.", ulNumber);
}
double dbl2 = 35901.997;
try {
long number2 = (long) dbl2;
Console.WriteLine(number2);
}
catch (OverflowException) {
Console.WriteLine("{0} is out of range of an Int64.", dbl2);
}
BigInteger bigNumber = (BigInteger) 1.63201978555e30;
try {
long number3 = (long) bigNumber;
Console.WriteLine(number3);
}
catch (OverflowException) {
Console.WriteLine("{0} is out of range of an Int64.", bigNumber);
}
// The example displays the following output:
// 163245617943825
// 35902
// 1,632,019,785,549,999,969,612,091,883,520 is out of range of an Int64.
Also in C#:
- Title
- c# round number down
- Category
- C#
- Title
- c# how to have a multiline console.writeline
- Category
- C#
- Title
- c# resize bitmap
- Category
- C#
- Title
- how to trigger event when a com device is connected in c#
- Category
- C#
- Title
- c# get time
- Category
- C#
- Title
- c# print
- Category
- C#
- Title
- how to reference function in unity
- Category
- C#
- Title
- unity load scene
- Category
- C#
- Title
- change z value unity
- Category
- C#
- Title
- how to go to other forms in C#
- Category
- C#
- Title
- override Microsoft.AspNetCore.Authorization.AuthorizeAttribute
- Category
- C#
- Title
- try catch c#
- Category
- C#
- Title
- displayname c#
- Category
- C#
- Title
- c# remove specific character from string
- Category
- C#
- Title
- unity getcomponent
- Category
- C#
- Title
- open file in explorer c#
- Category
- C#
- Title
- unity main texture not working
- Category
- C#
- Title
- c# request run as administrator
- Category
- C#
- Title
- how to turn a string in a char list c#
- Category
- C#
- Title
- unity gizmo draw line
- Category
- C#
- Title
- Unity3d GPS code
- Category
- C#
- Title
- c sharp list indexer
- Category
- C#
- Title
- No IUserTwoFactorTokenProvider<TUser> named 'Default' is registered.'
- Category
- C#
- Title
- how do I attach a player with a navMeshAgent
- Category
- C#
- Title
- count the number of notes in a given amount c#
- Category
- C#
- Title
- unity delete all children
- Category
- C#
- Title
- c# get list of all class fields
- Category
- C#
- Title
- how to see if they are aholding down a key unity
- Category
- C#
- Title
- c# distinct comparer multiple properties
- Category
- C#
- Title
- unity hide mouse
- Category
- C#
- Title
- arry in c#
- Category
- C#
- Title
- autoresetevent
- Category
- C#
- Title
- c# switct case
- Category
- C#
- Title
- how to detected WindowCloseEvent in other window wpf
- Category
- C#
- Title
- .net core download image from url binary file
- Category
- C#
- Title
- vb.net check if datatable has rows
- Category
- C#
- Title
- covert char[] to string C#
- Category
- C#
- Title
- c# httpclient azure function authorization
- Category
- C#
- Title
- unity custom update
- Category
- C#
- Title
- check distance to gameobject
- Category
- C#
- Title
- c# get every point in a line in matrix
- Category
- C#
- Title
- array to list C
- Category
- C#
- Title
- exception handling c# stack overflow
- Category
- C#
- Title
- unity collider2d contains point
- Category
- C#
- Title
- how to make an object move in unity
- Category
- C#
- Title
- c# instantiate
- Category
- C#
- Title
- how to delay something in c# unity
- Category
- C#
- Title
- c sharp index of substring
- Category
- C#
- Title
- get day month year from date c#
- Category
- C#
- Title
- C# extend array
- Category
- C#
- Title
- unity docs player input
- Category
- C#
- Title
- generate a dropdown list from array data using razor .net mvc
- Category
- C#
- Title
- idbset sqlquery
- Category
- C#
- Title
- unity button interactable
- Category
- C#
- Title
- c# round number up
- Category
- C#
- Title
- F# convert generic.List to list
- Category
- C#
- Title
- c# MD5.Create returning nul
- Category
- C#
- Title
- use newtonsoft json to clone object
- Category
- C#
- Title
- how to add an embedded resource in visual studio code
- Category
- C#
- Title
- Unity C# add slider into editor
- Category
- C#
- Title
- how to change an int value c#
- Category
- C#
- Title
- c# reverse array
- Category
- C#
- Title
- wpf binding ancestor codebehind
- Category
- C#
- Title
- C# resize window without title bar
- Category
- C#
- Title
- get random value from list c#
- Category
- C#
- Title
- c# discord bot
- Category
- C#
- Title
- how to spawn coins randomly around the screen unity 2d
- Category
- C#
- Title
- c# how to refreshyour bindingsource
- Category
- C#
- Title
- c# add object to array
- Category
- C#
- Title
- c# input
- Category
- C#
- Title
- example HttpClient c# Post
- Category
- C#
- Title
- unity how to add a bullet impact force
- Category
- C#
- Title
- asp.net core task iactionresult
- Category
- C#
- Title
- c# get object property value by name
- Category
- C#
- Title
- response redirect new tab
- Category
- C#
- Title
- decimals not stored in azure tables
- Category
- C#
- Title
- how to hide and show object in unity script
- Category
- C#
- Title
- remove all array elements c#
- Category
- C#
- Title
- c# ?
- Category
- C#
- Title
- unity rotate around point
- Category
- C#
- Title
- c# if statement
- Category
- C#
- Title
- c# quick "is" "as"
- Category
- C#
- Title
- grab reference from method parameter c#
- Category
- C#
- Title
- c# remove last value from list
- Category
- C#
- Title
- c# type of generic is string
- Category
- C#
- Title
- unity position ui element
- Category
- C#
- Title
- unity line renderer position count
- Category
- C#
- Title
- unity cast float to int
- Category
- C#
- Title
- change textbox location C#
- Category
- C#
- Title
- asp.net core redirecttoaction with parameters
- Category
- C#
- Title
- read in multiple numbers c#
- Category
- C#
- Title
- asp.net core mvc not triggering client side validation
- Category
- C#
- Title
- how to locate a specific element in a list c#
- Category
- C#
- Title
- text variable type unity
- Category
- C#
- Title
- unity create gameobject
- Category
- C#
- Title
- blazor wasm routable page in separate project
- Category
- C#
- Title
- cannot apply indexing with to an expression of type 'object'
- Category
- C#
- Title
- as c#
- Category
- C#
- Title
- c# window instantly close
- Category
- C#
- Title
- how to initiate a varaible in cs
- Category
- C#