D J
D J

Reputation: 7028

How to define constraints on multiple generics parameters

I am wondering why I cant get such simple thing like this on google. This code is not compilable. How can I do this?

public class TestStep<StartEvent, CompletedEvent> 
    where StartEvent : MyBase1, MyInterface1, new() &&
    where CompletedEvent : MyBase2, MyInterface2, new()
{
}

Please help.

Upvotes: 43

Views: 19353

Answers (1)

Greg Oks
Greg Oks

Reputation: 2730

Try without the "&&"

public class TestStep<StartEvent, CompletedEvent> 
    where StartEvent : MyBase1, MyInterface1, new()
    where CompletedEvent : MyBase2, MyInterface2, new()
{
}

Upvotes: 76

Related Questions