Move Type to Another File refactoring
This refactoring helps you move the selected type from the current file to any existing file or to a new file. If you are moving to a new file, the new file is created automatically. If there are no more types in the current file, it can be removed. All necessary imports are moved with the type. All imports that are no longer necessary are removed from the original file.
If you invoke this refactoring on a nested type, JetBrains Rider will make the parent class partial, create a new file for the new part of the partial class, and move the selected type there. If necessary, you can then use the Move Type to Outer Scope refactoring to make the type non-nested and remove the redundant part of the parent class.
Move a type to another file
Select a type in one of the following ways:
In the editor, place the caret at the name of a type.
Select a type in the Solution Explorer.
Select a type in the Structure window window.
Do one of the following:
Press F6 and then choose Move to Another File
Press Ctrl+Alt+Shift+T and then choose Move to Another File.
Choose
from the main menu.
The Move to Another File dialog will open.
Type a filename in the New file name field. You can specify the name for an existing file or a new one. In the latter case, the new file is created in the current project or folder.
To apply the refactoring, click Next.
If no conflicts are found, JetBrains Rider performs the refactoring immediately. Otherwise, it prompts you to resolve conflicts.
![JetBrains Rider. Move to another file refactoring JetBrains Rider. Move to another file refactoring](https://resources.jetbrains.com.cn/help/img/rider/2024.2/Refactorings__Move__Type_to_Another_File.png)