Question

When you have a generic class, with different type parameter overloads it seems generally accepted that you use the back-tick syntax in the file name:

MyType.cs
MyType`1.cs
MyType`2.cs

Is this the same for an interface? For example:

IRepository.cs
IRepository`2.cs

Where you have these corresponding type parameters:

public interface IRepository {

and

public interface IRepository<T, in TId> {
Was it helpful?

Solution

File conventions are just a personal/team preference. You could do this, if you so choose.

I, personally, tend to put these in the same file. If I'm looking for IRepository, I would assume that any and all IRepository interfaces are all similar, and all represent a "repository", so I'd just look for them in the same place. This would avoid needing to figure out which of the `2, etc, files to search through. For me, "IRepository`5.cs" is not more readable or discoverable than finding these all in one file.

OTHER TIPS

Yes.
This convention applies for all types of types – classes, interfaces, and delegates.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top