Visual Studio 2010:复制类的最简单方法? [英] Visual Studio 2010: Easiest way to duplicate a class?

查看:227
本文介绍了Visual Studio 2010:复制类的最简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有简单的方法来复制具有不同名称的类?

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

推荐答案

不确定是否可以将其作为最简单的方法,但是如果您有 ReSharper ,则可以使用其复制类型重构以控制要复制到的名称空间的类/接口/结构,并在其中复制名称-这意味着,如果您要复制具有5个构造函数的类,则该副本将重命名所有它们以匹配名称新班级的.

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.

这篇关于Visual Studio 2010:复制类的最简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆