KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In C# 3.0 you can use Expression to create a class with the following syntax: var exp = Expression.New(typeof(MyClass)); var lambda = LambdaExpression.Lambda(exp); object myObj = lambda.Compile().DynamicInvoke(); But how do you use Expression to create an Anonymous class? //anonymousType = typeof(new{ Name="abc", Num=123}); Type anonymousType = Expression.NewAnonymousType??? <--How to do ? var exp = Expression.New(anonymousType); var lambda = LambdaExpression.Lambda(exp); object myObj = lambda.Compile().DynamicInvoke();
Tags (comma-separated)
Save Edits
Cancel