Can I dynamically create a property type and property name for an (anonymous) object if the name and type I get from a string variable?
Can I dynamically create a property type and property name for an (anonymous) object
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you’re talking about anonymous types (such as
var x = new { Property1 = data1, ...}) then I don’t think that you can.What you might be able to do is create another new anonymous type from the one you already have. Where you want to create
YfromX, you could createYbyvar Y = new { YProp1 = X.Prop1, YProp2 = X.Prop2, etc}