Mega Code Archive

 
Categories / C# Tutorial / Data Type
 

Cast a uint into a short, no data lost

using System;    class Example {       public static void Main() {         uint u;      short s;           u = 32000;      s = (short) u;      Console.WriteLine("s after assigning 32000: " + s +                        " -- no data lost.");     } } s after assigning 32000: 32000 -- no data lost.