Visual Studio 2010: Easiest way to duplicate a class?

后端 未结 7 1452
深忆病人
深忆病人 2021-01-18 19:08

Is there an easy way to duplicate a class with a different name?

7条回答
  •  执念已碎
    2021-01-18 19:41

    Not sure whether this can be qualified as the easiest way but if you have ReSharper, you can use its Copy Type refactoring to copy classes/interfaces/structs with control over the namespace the copy is landing in and naming within the copy - which means that if you're copying a class with 5 constructors, the copy will have all of them renamed to match the name of the new class.

    However, depending on what you're trying to achieve, using Extract Interface or Extract Superclass might be a better option.

提交回复
热议问题