读书人

C#命名规范有关问题

发布时间: 2013-11-23 10:52:51 作者: rapoo

C#命名规范问题
C#创建windows应用程序时,自动生成的代码中,混杂了的中文变量名,比如:

this.contextMenuStrip2 = new System.Windows.Forms.ContextMenuStrip(this.components);
this.图像ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.文字ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.帮助ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.显示图像ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.旋转图像ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.添加文字ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.删除文字ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();

这是自动生成的代码,怎么没有符合Camel命名法,需要更改吗?
[解决办法]
图像ToolStripMenuItem是ToolStripMenuItem的Name. 可以在属性中设置。

ToolStripMenuItem的Name不要使用中文,Text中可以使用中文
[解决办法]
Name自己命名为中中文生成就是那样,名字一般不要用中文!起一个个有意义的英文名字
[解决办法]
你在 ToolStripMenuItem 的属性窗口用把Name改下就可以了
[解决办法]
所以结论就是,你应该使用英文版的Visual Studio。
[解决办法]
自己修改Name

读书人网 >C#

热点推荐