In your case you are trying to use null
as a sentinel value (a "default") instead of actually needing to store null
as a value. Rather than go to the hassle of creating a dictionary that can accept null keys, why not just create your own sentinel value. This is a variation on the "null object pattern":
class Switch
{
private class DefaultClass { }
....
public void Execute(object obj)
{
var type = obj.GetType();
Action
Note that your first Execute
function differs significantly from your second. It may be the case that you want something like this:
public void Execute(object obj)
{
Execute(obj, (IEnumerable>>)_dict);
}
public static void Execute(object obj, params KeyValuePair>[] cases)
{
Execute(obj, (IEnumerable>>)cases);
}
public static void Execute(object obj, IEnumerable>> cases)
{
var type = obj.GetType();
Action