Why prefix C# interface names with an “I”

前端 未结 18 1576
清歌不尽
清歌不尽 2021-02-01 03:13

What is the rationale behind this naming convention?

I don\'t see any benefit. The extra prefix just pollutes the API.

My thinking is inline with Konrad\'s respo

18条回答
  •  野的像风
    2021-02-01 03:41

    The "I" convention seems to be an old convention that wouldn't be relevant today. Current code editor provides lots of insight about the type you are using, so arguing that It's easier to identify the interface is like asking for a namespace to be prefixed by a "N" because you want to be sure that you will not confound it with a concrete class (prefix with a "C"?).

    A convention doesn't mean that It's a good convention. Sometimes, It's just because people get to use it...

    Take for example the C# documentation generator: It doesn't care about it... if your interface is not prefixed with a "I" you will still see your interface in the interface part of your documentation. Do you really think that having a prefix "I" for all your interfaces inside the interface section of your documentation is a relevant information and help you to better identify interfaces?

提交回复
热议问题