Can a type be accessed like a dictionary directly without using a static member?
This could be a flawed design pattern, but I thought I would ask to be sure I am doing it the only way possible.
This works:
public static class StuffManager
{
public static readonly StuffDict Stuff = new StuffDict();
}
public class StuffDict : IDictionary<string, string>
{
// custom dictionary stuff
}
Here a user has to type:
string athing = StuffManager.Stuff["key"]
.
This is what I am wondering about....
public static class StuffManager : IDictionary<string, string>
{
// custom dictionary stuff
}
If this worked, a user would instead type:
string athing = StuffManager["key"]
I'm fine if the answer is "no" I just want confirmation that the second pattern is either not possible or a bad idea. If it is relevant, this is for use as a sort-of plugin in a 3rd par开发者_开发百科ty application where a user would add my .cs files than be a user from inside the same application.
Thank you.
No, that's not possible.
It doesn't make sense for a static class to inherit from a non-static class. Any inherited instance members would still be instance members, and couldn't be used from the static class.
精彩评论