命名事件处理程序:如何使第一个字母大写
我通常以小写字母开头来命名窗口应用程序的控件。例如:
startButton
optionsListBox
当我订阅(通过VS)这些控件之一的事件时,它会自动给出如下名称:
startButton_Click< /代码>
optionsListBox_SelectedIndexChanged
但 ReSharper 建议将其重命名为:
StartButtonClick
OptionsListBoxSelectedIndexChanged
阅读ReSharper 事件处理程序名称约定 我看到我可以通过 ReSharper 修改事件处理程序的命名方式。 例如:
从$object$_On$event$
到$object$On$event$
。这将删除 _
字符,但是第一个字母呢?
有没有办法告诉VS或ReSharper默认将事件处理程序名称设置为大写?
I usually name the controls of my window application starting with a lowercase letter. Eg:
startButton
optionsListBox
And when I suscribe (through VS) to an event of one of those controls, it automatically gives names like:
startButton_Click
optionsListBox_SelectedIndexChanged
but ReSharper suggests renaming it to:
StartButtonClick
OptionsListBoxSelectedIndexChanged
Reading ReSharper conventions for names of event handlers I saw I can modify through ReSharper how event handlers will be named. Eg:
From $object$_On$event$
to $object$On$event$
. That will remove the _
character, but what about the first letter?
Is there a way to tell VS or ReSharper to make event handler names uppercase by default?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Visual Studio 2010 的“EventHandler Naming”扩展允许您精确配置如何从 Visual Studio 设计器生成事件处理程序。
例如,您可以使用“On$(SiteName)$(EventName)”对其进行配置,然后指定 SiteName 应采用 PascalCased。
该扩展可以在此处下载
The "EventHandler Naming" extension for Visual Studio 2010 allows you to configure precisely how to generate event handlers from the visual studio designer.
For instance you could configure it with "On$(SiteName)$(EventName)" and then specify that the SiteName should be PascalCased.
The extension can be downloaded here