问题
Is there a way to create a template in ReSharper that capitalizes a name?
For example I'd like to do something like this:
private $type$ _$name$;
public $type$ $uppercase_name$
{
get { return _$name$; }
set { _$name$ = value; }
}
So when I enter "city" for $name$, $uppercase_name$ should automatically be "City".
回答1:
Ok I did it:
- When adding a template, on the right there's a part where you can choose a macro. Click on "Choose Macro" for
uppercase_name. - Go to the end of the list. There's a macro called "Value of another variable with the first character in upper case". Choose that.
- The part "another variable" will be in red in the macro selection part. Click on that.
- Choose
name.
Enjoy!
P.S. I have ReSharper 7.1. This may not be applicable for earlier versions.
来源:https://stackoverflow.com/questions/15342501/captilizing-a-name-in-a-resharper-template