'Dynamic Dictionary values c#

I have a string key 'KEY' and different data types values like:

int id 
String name
Object obj
Long storage 

How can I store these variables in a Dictionary against a single key?



Solution 1:[1]

Do you mean something like this:

class MyThing
{
  public int Id {get;set;}
  public string Name {get;set;}
  public object Obj {get;set;}
  public long Storage {get;set;}
}      

Dictionary<string, MyThing> myDictionary = new Dictionary<string, MyThing>
{
   ["key1"] = new MyThing { Id = 1 },
   ["key2"] = new MyThing { Name = "Fred" },
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Neil