The use of the cast operator : Data Type Cast : Data Type C# Examples


C# Examples » Data Type » Data Type Cast »

 

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



Output

myShort = 17000
myInt = 17000
myShort = -31536


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Data Type
» Data Type Cast