Code below is working well as long as I have class ClassSameAssembly
in same assembly as class Program
.
But when I move class ClassSameAssemb
If you're already using Newtonsoft.Json in your project (or you're willing to add it for this purpose), you could implement that horrible extension method Jon Skeet is referring to in his answer like this:
public static class ObjectExtensions
{
public static ExpandoObject ToExpando(this object obj)
=> JsonConvert.DeserializeObject(JsonConvert.SerializeObject(obj));
}