views:

57

answers:

1

This question is similar, but my question seems to get asked in an unanswered comment.

I create a C# class. I use alt-insert to add a constructor. I add an argument to the constructor, and then I use alt-enter to create and initialize a field from that argument, like so:

alt text

The problem is that my field gets created as a readonly field, and in many cases I do not want to create a readonly field.

readonly int my_int;

How can I tell ReSharper not to add make my field readonly? I've tried to do a pretty thorough search in the ReSharper options, but apparently I'm missing something!

+1  A: 

I too cannot find any option to change the creation default; however, if you allow R# to create this field as it likes (ie readonly), and later type this:

public void Bar(int baz)
{
    my_int = baz;
}

then the assignment to my_int will get a red squiggly underline, since it is illegal, and the offered quick fix (Alt+Enter) at that location will be Make field 'my_int' non-readonly.

So in the spirit of 'code first', you might want to just let R# do its thing, and also use it to change it as and when you actually need it changed (which might of course turn out to be never...)

AakashM

related questions