I'm using JSON.NET to deserialize a JSON file to a dynamic
object in C#.
Inside a method, I would like to pass in a string
and refer to that specified attribute in the dynamic object.
For example:
public void Update(string Key, string Value)
{
File.Key = Value;
}
Where File
is the dynamic object, and Key
is the string that gets passed in. Say I'd like to pass in the key "foo" and a value of "bar", I would do:
Update("foo", "bar");
, however due to the nature of the dynamic
object type, this results in
{
"Key":"bar"
}
As opposed to:
{
"foo":"bar"
}
Is it possible to do what I'm asking here with the dynamic object?