To use the 'I' prefix for interfaces or not to

前端 未结 20 1475
长情又很酷
长情又很酷 2021-02-01 02:54

That is the question? So how big a sin is it not to use this convention when developing a c# project? This convention is widely used in the .NET class library. However, I am not

20条回答
  •  长情又很酷
    2021-02-01 03:46

    The key thing is consistency - as long you stick to having I prefixed to all interfaces or none at all, it's a matter of preference.

    I use the I prefix for interfaces at work since the existing code already uses it for a naming convention for each interface. I find it more intuitive to quickly determine if a class implements an interface or another class simply by looking for the I prefix in the name of the base class.

    On the other hand, some of the older projects at work don't use this naming convention and this makes the code slightly less readable, but it might just be that I'm used to the prefix.

提交回复
热议问题