user338195
user338195

Reputation:

C# Generics syntax help

I can't figure out the correct sytax for the following:

public interface IRepository<T,E> where T E: class

Looked a lot online, but articles don't seem to cover two classes.

Thank you

Upvotes: 1

Views: 152

Answers (2)

Justin Niessner
Justin Niessner

Reputation: 245419

From the "Constraining Multiple Parameters" section of Constraints on Type Parameters (MSDN):

public interface IRepository<T, E> 
    where T : class
    where E : class

Upvotes: 9

Yves M.
Yves M.

Reputation: 3318

public interface IRepository<T,E> 
where T: class
where E: class 

Upvotes: 4

Related Questions