- using System;
- using System.Text;
- namespace forgetCode
- {
- class program
- {
- public static void Main()
- {
- int value1 = 124;
- long value2 = (long)value1;
- Console.WriteLine(value2);
- }
- }
- }
- using System;
- using System.Text;
- namespace forgetCode
- {
- class program
- {
- public static void Main()
- {
- // Assign integer and then cast it to an object implictly.
- int value1 = 124;
- object value2 = value1;
- // Explicitly cast to long again from the object type.
- //unProper casting
- long value3 = (long)value2;
- Console.WriteLine(value3);
- }
- }
- }