Mega Code Archive

 
Categories / C# Tutorial / Data Type
 

The use of the cast operator

class MainClass {   public static void Main()   {     short myShort = 17000;     System.Console.WriteLine("myShort = " + myShort);     int myInt = myShort;     System.Console.WriteLine("myInt = " + myInt);     myShort = (short) (myInt * 2);     System.Console.WriteLine("myShort = " + myShort);   } } myShort = 17000 myInt = 17000 myShort = -31536