C# equivalent of Java Class<? extends Base>?

I'd like to be able to write a method in C# similar to how I would in Java... To pass in a Class object that is a subclass of some super class... but the best I can find for C# is the following:

public void someMethod(Type t) {
  if (t == typeof(SomeType)) ...
}

Is there any way I can enforce in the method signature that the parameter has to be either the type SomeType or one of its inheritors?

I'm not looking to pass in an instance of said Type. I want to pass the Type itself in as a parameter.

Edit

Here's a bit of context.

I want to make an EventManager class that contains a Dictionary<SomeEventType, ICollection<EventHandler>> object, and a method registerEventHandler(Type t, EventHandler eh) that maps a given Type to an EventHandler.

In Java, I would accomplish it as such:

private static Map<Class<? extends Event>, Collection<EventHandler>> eventHandlers;

public static void registerListener(Class<? extends Event> event, EventHandler handler) {
  if (eventHandlers.get(event) == null) {
    HashMap<EventHandler> handlers = new HashMap<EventHandler>()
    eventHandlers.put(event, handlers) ...
  }
}
Jon Skeet
people
quotationmark

As others have said, you can do this with a generic type parameter... but if you only have the value as a Type and want to pass it in as a regular argument (e.g. because it's been passed to your method that way), there's no way of doing it. Type isn't generic in .NET, so there's no concept of constraining the parameter to be the Type representing a particular class or its subclasses, just as there's no concept of constraining a string parameter to be of a certain length or longer.

If you do know the types at compile-time when calling the method, then using a generic type parameter as per recursive's answer is absolutely the way to go.

people

See more on this question at Stackoverflow