-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,283
  • 1
  • 21
  • 26
monther zlatan
  • 156
  • 1
  • 14

2 Answers2

4

You need to use where constraint clause:

public class SomeClass<T>
   where T : SomeInterface
{}
Eugene Podskal
  • 10,270
  • 5
  • 31
  • 53
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