vendredi 30 octobre 2015

Create Anonymous object from Dictionary

Today I got stuck at one point where I need to convert a Dictionary<String,String> to an anonymous object. Is there any one who has tried this before. Below is the example what I actually need.

var dict = new Dictionary<string, object> 
{
    { "CourseId", "XDX123BH" }, 
    { "PersonID", "JIHJ98KH" } 
};

Though this object I want to create is an anonymous object like:

new {CourseID = "XDX123BH", PersonId = "JIHJ98KH" }

Is it possible to do this?





Aucun commentaire:

Enregistrer un commentaire