C# Type Casting : cast double to int.



Casting must be done manually by placing the type in parentheses in front of the value.

double myDouble = 11.78;
int myInt = (int) myDouble; // Manual casting: double to int
Console.WriteLine(myDouble); // Outputs 11.78
Console.WriteLine(myInt); // Outputs 11

0 Comment's

Comment Form

Submit Comment