Skip to content

Dynamic creating Anonymous (similar) Types at program runtime

License

Notifications You must be signed in to change notification settings

mustaddon/DynamicAnonymousType

Repository files navigation

DynamicAnonymousType NuGet version

Dynamic creating Anonymous (similar) Types at program runtime.

using DynamicAnonymousType;


Type type = DynamicFactory.CreateType(
    ("Id", typeof(int)),
    ("Name", typeof(string)),
    ("Date", typeof(DateTime?)));

dynamic instance = type.CreateInstance(
    ("Id", 1),
    ("Name", "Text1"),
    ("Date", DateTime.Now));

Program.cs