Using casts in an expression
/*
C#: The Complete Reference
by Herbert Schildt
Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Using casts in an expression.
using System;
public class CastExpr {
public static void Main() {
double n;
for(n = 1.0; n <= 10; n++) {
Console.WriteLine("The square root of {0} is {1}",
n, Math.Sqrt(n));
Console.WriteLine("Whole number part: {0}" ,
(int) Math.Sqrt(n));
Console.WriteLine("Fractional part: {0}",
Math.Sqrt(n) - (int) Math.Sqrt(n) );
Console.WriteLine();
}
}
}
Related examples in the same category