// Collection of code snippets by Arne Vajhøj // (from articles on eksperten.dk / vajhoej.dk written sometime between 2004 and now) using System; namespace E { public class Program { public static void Test(object o) { if(o is int vi) { Console.WriteLine(vi); } if(o is string vs) { Console.WriteLine(vs); } } public static void Main(string[] args) { Test(123); Test("ABC"); } } }