Answers for "c# create dictionay from object"

C#
0

c# object to dictionary

public static Dictionary<string, TValue> ToDictionary<TValue>(object obj)
{       
    var json = JsonConvert.SerializeObject(obj);
    var dictionary = JsonConvert.DeserializeObject<Dictionary<string, TValue>>(json);   
    return dictionary;
}
Posted by: Guest on November-10-2021
0

C# dictionnaries

using System.Collections.Generic;

Dictionary<TKey,TValue> dictionary = new Dictionary<TKey,TValue>();

dictionary.Add(TKey, TValue);

//Returms a booleen
dictionary.TryGetValue(TKey, out TValue tValue);
Posted by: Guest on August-27-2021

C# Answers by Framework

Browse Popular Code Answers by Language