rename class with file name in one step in Visual Studio

后端 未结 6 1778
醉酒成梦
醉酒成梦 2021-02-18 13:29

I am a long year Java programmer, but currently I code in C#. I am accustomed, that when I change filename, also the class name changes and vice versa. This doesn\'t work in my

6条回答
  •  我在风中等你
    2021-02-18 14:04

    It seems to not work when the copied file is in the same folder and the class name is the same (which it will be if you just copied the file). I think the reasoning may be that rename doesn't descriminate between a class in a newly copied file and the original (See comment below by @xMichal).

    The quick solution is to copy the file (I use ctrl+drag) into a nearby folder, rename, then move it back.

    Another option (which may be Resharper specific), is to rename the class (and constructors) in the copied file, then use the tooltip to electively rename the file to match.

提交回复
热议问题