如何避免类名和名称空间冲突? [英] How to avoid class name and namespace conflict?

查看:98
本文介绍了如何避免类名和名称空间冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时我需要调用名称空间并对其进行相同的分类.例如,SomeProject.Compiler命名空间,其中包含许多与编译器相关的内容和主入口点类Compiler.但是不建议将名称空间和类名称命名为相同名称,因为这会造成歧义并误导编译器.
有什么想法,如何给它们起更好的名字?

Sometimes I have need to call namespace and class the same. For example, SomeProject.Compiler namespace, containing lots of compiler-related stuff and the main entry point class Compiler. But naming namespace and class name the same is not recommended, as it creates ambiguity and misleads compiler.
Is there any idea, how to name them better?

推荐答案

始终可以提供通用名称空间名称,该名称描述了其所有成员.例如,使用CompilerServices而不是编译器.

It is always possible to give general namespace name, which describes all its members. For example, CompilerServices instead of compiler.

这篇关于如何避免类名和名称空间冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆