C# – Get value from dictionary

Dictionaries store key/value pairs. When you want to get the value for a key, you can use the indexer syntax and specify the key, like this: Note: In order to show how to get a value, I had to initialize the dictionary with key/value pairs. This returns the value associated with the “Bob” key and … Read more

C# – Deserialize JSON using different property names

When JSON property names and class property names are different, and you can’t just change the names to match, you have three options: These options affect both deserialization and serialization. Let’s say you have the following JSON with camel-cased property names: Here’s an example of using the JsonPropertyName attribute: Note: The Newtonsoft equivalent is [JsonProperty(“title”)] … Read more