static void TypeDefs() { try { object o1 = ""; newObj.i = 1; SNS ObjSns = (SNS)o1; // this casting return error if the casing is not successful SNS ObjSns_1 = o1 as SNS; // this one will return null if casing is not successful. //int? o1int = o1 as int?; object o2 = 1; var a1 = 1; var a2 = ""; // a2 = new SNS(); } catch (Exception e) { Console.WriteLine("Message : " + e.Message); } }
static void StaticAndNonStaticExample() { SNS s1 = new SNS(); Console.WriteLine(s1.ToString()); }