Demonstrate dynamic initialization : Variable Definition : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Variable Definition »

 

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); 
 
  }  
}


           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Variable Definition