Question: in C# I need to keep data in a dictionary object, looks like:

```
Dictionary<string, Dictionary<string, string>> MyDict = 
    new Dictionary<string, Dictionary<string, string>>();

```

Now I realised, that I would need in some cases some other (not dictionary-like) data as value of the main dict.

Is there any kind of Problem or limitation, if I just instance the main dict. as:

```
Dictionary<string, object> MyDict = new Dictionary<string, object>();

```

in the object field I could put string, dictionary, whatever..

Thanks in advance,
Best regards, Steven

Answer: 
By using object as the value in your dictionary you will incur some risk and complications:

* Lack of type safety (anything can be set to the value)
* You would have to cast to a particular type, probably based on the value

You should probably rethink your design. But if you really want a the flexibility you could create a new type that would work as the value type. Something like:

```
class MySpecialType
{
    public Dictionary<string, string> MyStringDictionary { get; set; }
    public string MyStringVal {get; set;}

    public Type ActiveType { get; set; } // property would specify the current type
    // ...

```

Your main dictionary declaration would then look something like:

```
Dictionary<string, MySpecialType> MyDict = new Dictionary<string, MySpecialType>();

```

You could use the ActiveType property or create an enum which would specify the type. You could also have static util functions in the class which could help with returning the right instance and type...
You will pay a performance penalty when you [unbox](http://msdn.microsoft.com/en-us/library/yz2be5wk.aspx) the `System.Object`, but other than that there isn't a problem with your approach other than excessive casting for indexers (*due to weak typing*). 

You may consider using a [System.Tuple](http://msdn.microsoft.com/en-us/library/system.tuple.aspx) if you are using .NET 4.