using System; using System.Text; namespace forgetCode { class program { public static void Main() { // Assign long and then cast it to an object implictly. long value1 = 124124; object value2 = value1; // Explicitly cast to long again from the object type. //Proper casting long value3 = (long)value2; Console.WriteLine(value3); } } }
using System; using System.Text; namespace forgetCode { class program { public static void Main() { // Assign long and then cast it to an object implictly. long value1 = 124124; object value2 = value1; // Explicitly cast to string from the object type. //Error case // Unable to convert from "Long object type" to string string value3 = (string)value2; Console.WriteLine(value3); } } }