在Visual Studio中从属性生成字段的快捷方式

时间:2014-07-31 07:34:10

标签: visual-studio-2012 shortcut

VS中是否有任何快捷方式可以从相应的属性定义字段?

1 个答案:

答案 0 :(得分:10)

如果您要为自动生成的属性生成后备存储:

 public string MyProperty { get; set; }

要:

 public string _myProperty;
 public string MyProperty { 
      get { return _myProperty; } 
      set { _myProperty = value; } 
 }

然后在Visual Studio中没有快捷方式。像Resharper and CodeRush这样的重构工具提供了此功能。

在Visual Studio中,"Encapsulate field"重构可以反过来 ctrl + r e 。< / p>

 public string _myProperty;

要:

 public string _myProperty;
 public string MyProperty { 
      get { return _myProperty; } 
      set { _myProperty = value; } 
 }
相关问题