fork download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. public static void Main()
  6. {
  7. object s, s2;
  8. s = Convert.ToInt16(10);
  9. s2 = 10;
  10. Console.WriteLine("Types: {0} and {1}", s.GetType(), s2.GetType());
  11. Console.WriteLine("s as Int16 (works): {0}", (Int16)s);
  12. Console.WriteLine("s2 as Int16 (error): {0}", (Int16)((Int32)s2));
  13. }
  14. }
Success #stdin #stdout 0.03s 33904KB
stdin
Standard input is empty
stdout
Types: System.Int16 and System.Int32
s as Int16 (works): 10
s2 as Int16 (error): 10