Should you prefix interfaces with I in C#? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Should you prefix interfaces with I in C#?

Microsoft suggests you should as a naming convention but Robert Martin in the book Clean Code says that you shouldn't use Hungarian notation anymore as it is outdated and no longer needed. What do people think and do in their own code?

18th May 2019, 12:03 PM
Roy Marler
2 Answers
+ 2
You should use I for interfaces. Interfaces are shown to the outside world. Being able to differ a class from a interface is important. Robert Martin talks about variables. So Use I for interface And do not use any prefixes for variables. According to Robert Martin interfaces are bad any way
18th May 2019, 12:59 PM
sneeze - avatar
I have a naming convension I stick to. I inherited it from Python's pep8 Basically: - normal_variables are lowercase. With underscore if more than one word - temporary variables are a single lowercase letter - function names use PascalCase and no underscores - similar functions use the same parameter names I think this about sums it up🤔
18th May 2019, 12:38 PM
Trigger - avatar