Maksim Vi. Maksim Vi. - 1 year ago 85
ASP.NET (C#) Question

Asp.Net Deserialize Dictionary<string, object> to an object

What would be the best way to deserialize this

Dictionary<string, object>{
{"fName", "John"},
{"lName", "Doe"},
{"email", ""}

to this

class Member{
string fName;
string lName;
string email;

Answer Source

This isn't really serialization in the normal sense, that usually refers to taking some disk or network formatted data (binary, ASCII, JSON etc) and loading it into a runtime object.

However, if I understand you correctly, I think what you are trying to do is...

public Member( Dictionary<string,object> dictionary )
    fName = dictionary["fName"];
    lName = dictionary["lName"];
    email = dictionary["email"];

// usage Member m = new Member( inputDictionary );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download