public static void Main()
var intType = typeof(int);
var intAsObject = GetAsType<object>(intType);
WriteOutInfo(intAsObject);
var sampleType = typeof(SampleClass);
var sampleAsObject = GetAsType<object>(sampleType);
WriteOutInfo(sampleAsObject);
private static T GetAsType<T>(Type type)
return (T)Activator.CreateInstance(type);
private static void WriteOutInfo(object obj)
var currentType = obj.GetType();
Console.WriteLine($"Type of object is {currentType.FullName} with methods:");
var methodNames = currentType.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance).Select(m => m.Name);
Console.WriteLine(string.Join(", ", methodNames));