The requested page is not available for the requested platform. You are viewing the content for Default platform.

Move Type to File

Moves a type to a new code file.

Availability

Available from the context menu or via shortcuts:

  • when the caret is on a type declaration and the file contains two or more types. The class should have a name that differs from the file name.
Note

The refactoring is not available within shared projects.

Notes

  • This refactoring creates a new file with the same name as the type at the caret, adds the file to the project, and then moves the type to that file.
  • All leading comments, attributes, and XML doc comments are moved to the new file together with the class itself.

Example

public class Person 
{
    public Person(string fName) 
    {
        this.fName = fName;
    }
    private string fName;
    public string Name {
        get {
            return fName;
        }
        set {
            fName = value;
        }
    }
}
Public Class Person
    Public Sub Person(ByRef fName As String)
        Me.fName = fName
    End Sub
    Private fName As String
    Private Property Name() As String
        Get
            Return fName
        End Get
        Set(ByVal value As String)
            fName = value
        End Set
    End Property
End Class

Animation

rsMoveTypeToFile

See Also