.netvisual-studioproject-types

Type of a project that contains only interfaces?


I am planning to use interfaces in my .NET project. I would like to add a new project "MyInterfaces" in my existing solution. "MyInterfaces" will contain all interfaces required by the solution.

But I am somewhat confused about the project type. What project type should "MyInterfaces" have? Class Library, or something else?

Then, what type of item would I add into that project to declare an interface? Interface or class?


Solution

  • Yes, it should be a class library. You'd then add an interface to the project - if you added a class, you'd have... well, a class! (Of course, you can add a class and then just change it to an interface declaration - as far as Visual Studio is concerned it's just a C# file; the "Add new item" part is just changing the initial template in this case.)

    If the problem is the name of the project type being "class library" rather than "interface library", ignore that - it's really just an assembly which doesn't include an entry point.