-1

How can I do this in C#?

  public class SomeClass<T extends  SomeInterface>{}

This is a generic class of T, and T must implement the interface SomeInterface.

hunch_hunch
  • 2,271
  • 1
  • 19
  • 26
monther zlatan
  • 162
  • 1
  • 13

2 Answers2

4

You need to use where constraint clause:

public class SomeClass<T>
   where T : SomeInterface
{}
Eugene Podskal
  • 10,047
  • 5
  • 30
  • 52
2

With type constraints:

public class SomeClass<T> where T : SomeInterface

See: http://msdn.microsoft.com/en-us/library/d5x73970.aspx

Peter Bucher
  • 295
  • 2
  • 13