W
Wonko the Sane
Hi All,
I’m sure it’s because my brain is fried, but I can’t figure something
(seemingly simple) out.
I have created a set of classes to “simplify†a set of things that I am
working on. This is currently the entire class:
internal class MySettingsDictionary : Dictionary<string, UserDefinedClass>
{
}
I also have a function in another class that returns something of the same
Dictionary type:
public static Dictionary<string, UserDefinedClass>
GetSettingsDictionary()
{
return mSettings;
}
The question is, is there a simple way to convert the return of the function
to the type?
At runtime, this returns null:
MySettingsDictionary settings = ClassA.GetSettingsDictionary as
MySettingsDictionary;
and this throws an InvalidCastException:
MySettingsDictionary settings = (MySettingsDictionary)
AClass.GetSettingsDictionary();
Thanks,
WtS
I’m sure it’s because my brain is fried, but I can’t figure something
(seemingly simple) out.
I have created a set of classes to “simplify†a set of things that I am
working on. This is currently the entire class:
internal class MySettingsDictionary : Dictionary<string, UserDefinedClass>
{
}
I also have a function in another class that returns something of the same
Dictionary type:
public static Dictionary<string, UserDefinedClass>
GetSettingsDictionary()
{
return mSettings;
}
The question is, is there a simple way to convert the return of the function
to the type?
At runtime, this returns null:
MySettingsDictionary settings = ClassA.GetSettingsDictionary as
MySettingsDictionary;
and this throws an InvalidCastException:
MySettingsDictionary settings = (MySettingsDictionary)
AClass.GetSettingsDictionary();
Thanks,
WtS