tags:

views:

128

answers:

3

When I create a constructor with parameters using Resharper's 'Generate code' feature, I get something like this:

public class Example{
     private int _x;
     private int _y;

     public Example(int _x, int _y){
         this._x = _x;
         this._y = _y;
     }
}

I would like to use this naming convention instead:

public class Example{
     private int _x;
     private int _y;

     public Example(int x, int y){
         _x = x;
         _y = y;
     }
}

but I don't know if it's possible to edit this constructor template and where.

+1  A: 

Go to Resharper -> Live Templates -> C# -> find the class and the ctor templates and right click on them to make the desired adjustments ...

This may help you as well Live Templates help

afgallo
I see the parameterless (default) constructor template, but I don't see the one with parameters, do you see it ?
Rismo
Ok...I would declare my class normally with all my properties and then go ALT + INS and pick up the properties you want .... the generated code looks like with the naming convetion you wanted ....
afgallo
A: 

That is the sample I just created:

internal class MyClass { private string myField;

    public MyClass(string myField)
    {
        this.myField = myField;
    }
}
afgallo
+3  A: 

Options / Languages / Common / Naming Style You should set your field prefix to underscore.

Ilya Ryzhenkov
Thanks! That was it :D
Rismo

related questions