Change “Implement interface” template in Visual Studio

戏子无情 提交于 2019-12-01 21:09:36

问题


I'm constantly using the "Implement interface" shortcut in Visual Studio 2008. My "problem" is that i want Visual Studio to use the String-alias instead of string in every instance.

Since i'm forced to use String instead of string this would save me a great ammount of time. For example, i want the following:

public Catalogue(String url) { }

instead of

public Catalogue(string url) { }

Is this possible? Where do I find these templates?


回答1:


You cannot change the templates used during refactorings.

Templates that you can change are available in %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE. Specifically, most of the CSharp ones for blank files and such are in %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp

Maybe the person forcing you to use "String" would change their ways if they realized how much time this wasted. I personally don't understand this...

The IDE uses "string", and not "String" in all generated code - so by forcing a non-standard "standard" your team is inviting inconsistency. People can debate about which is better until they're blue in the face - but as you point out, using "String" is a pain in the ass.




回答2:


just replace string with String (whole word, case sensitive) or don't use this factoring template. because after examination %ProgramFiles%\Microsoft Visual Studio 9.0\Common7\IDE\ it seems to be hardcoded



来源:https://stackoverflow.com/questions/877345/change-implement-interface-template-in-visual-studio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!