Initializing a variable. : Variable Definition : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » Variable Definition »

 

Initializing a variable.








    
 

using System;

class MainClass{
    public static void Main() {
        // Initialize a variable at declaration
        short x = 5;

        // Initialize a variable as a copy of another
        int y = x;

        double z = y + 10.25;

        int a = (int)z;

        Console.WriteLine("X = {0} Y = {1} Z = {2}", x, y, z);
        Console.WriteLine("A = {0}", a);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» Variable Definition