I was assigned on a project (C# based) to work on, and i found there is a class and interface with same name in the same namespace [class : Payment, Interface : Payment]. so when i build the solution it gives me error that it is not allowed.
Renaming one of them will affect other many areas in the solution. Actually I don't know how was it working!!
Any ideas?
Thanks,
It's not possible to have two types with the same name under the same namespace (this is one reason why namespaces are useful).
A good convention is to have the letter I
before interface names, see: IEnumerable , ISerializable ...
If you must keep the identical names, you may change the namespace
of one of the types and change the using namespace
declaration accordingly.
Here is a nice explanation for your question. It's about Java but I think best practices can be similar about naming.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.