here is what I would like to do:
Dictionary<string,Dictionary<string, XxXxXx>> BoB;
where
XxXxXx can be class A, class B, class C...etc
and {A,B,C}:Class Z
so that i can declare (roughly-Pseudo)
class Rusty
{
private Dictionary<String,A> _a;
private Dictionary<String,B> _b;
private Dictionary<String,C> _c;
public Dictionary<String,????> Lookup( identifier id)
{
switch(id)
{
case id.a: return _a;
case id.b: return _b;
case id.c: return _c;}
}
}
}
yet the closest I can get results in:
CS1502, CS0029, CS0039 X|
Cannot convert type 'System.Collections.Generic.Dictionary<string,ClassA>' to 'System.Collections.Generic.Dictionary<string,ClassZ>' via a reference conversion, boxing conversion, unboxing conversion, wrapping conversion, or null type conversion
..basically says that what i have above can't be done..
couldn't find a decent reference for this type of "issue":confused:
any ideas?
As per aspdevdotnet's suggestion(thank you)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Jumba
{
class A:Z
{
}
class B:Z
{
}
class C:Z
{
}
class Z
{
}
class Y
{
Dictionary<string, Dictionary<string,Z>> Bob = new Dictionary<string,Dictionary<string,Z>>();
Dictionary<string, A> _a = new Dictionary<string,A>();
Dictionary<string, B> _b = new Dictionary<string,B>();
Dictionary<string, C> _c = new Dictionary<string,C>();
public Y()
{
Bob.Add("a",_a);
Bob.Add("b",_b);
Bob.Add("c",_c);
}
public Dictionary<string, Z> Retrieve(string str)
{
Object alpha = Bob[str];
if (alpha is A){return (alpha as A)}
}
}
}