I have a dictionary <Key, value> which needs to be populated to a C# class. C# property names will be same as key from dictionary and need to assign value from dictionary to properties. How can I do that dynamically ?
var dict = new Dictionary<String, String>();
dict.Add(firstname, "David");
dict.Add(lastname, "Paul");
dict.Add(address, "123 Lincoln Ave");
dict.Add(state, "CA");
dict.Add(zipcode, "84844");
public class sample
{
public string firstname { get; set; }
public string lastname { get; set; }
public string address { get; set; }
public string zipcode { get; set; }
public string state { get; set; }
}