Demonstrate dynamic initialization
/*
C#: The Complete Reference
by Herbert Schildt
Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Demonstrate dynamic initialization.
using System;
public class DynInit {
public static void Main() {
double s1 = 4.0, s2 = 5.0; // length of sides
// dynamically initialize hypot
double hypot = Math.Sqrt( (s1 * s1) + (s2 * s2) );
Console.Write("Hypotenuse of triangle with sides " +
s1 + " by " + s2 + " is ");
Console.WriteLine("{0:#.###}.", hypot);
}
}
Related examples in the same category