Skip to content

Instantly share code, notes, and snippets.

@jerry4
Created November 22, 2014 23:09
Show Gist options
  • Save jerry4/2e3f64c7abf23daf8295 to your computer and use it in GitHub Desktop.
Save jerry4/2e3f64c7abf23daf8295 to your computer and use it in GitHub Desktop.
create fields from anonymous type
// resharper has a refactoring for this but I use it in LinqPad. This works for very simple cases to save me some typing
foreach(var prop in anon.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public))
{
Console.WriteLine("\tpublic {0} {1};", prop.PropertyType, prop.Name);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment