相关疑难解决方法(0)

ReSharper 7.1"对具有支撑场的属性"将场移动到位

我最近升级到R#7.1并且我遇到了这个问题,其中To Property With Backing Field动作取代了我的支持字段并将它们移到了类的顶部.

例:

第1步:定义一个自动属性:

public class MyClass
{
    //... Lots of members here

    public int MyNewProperty {get;set;} // <- Create auto Property
}
Run Code Online (Sandbox Code Playgroud)

第2步:ReSharper的"带有支持领域的财产"

在此输入图像描述

预期结果:

public class MyClass
{
    //... Lots of members here

    private int _myNewProperty; // <- Backing field immediately above property
    public int MyNewProperty 
    {
       get
       {
           return _myNewProperty;
       }
       set
       {
           _myNewProperty = value;
       }
    }
}
Run Code Online (Sandbox Code Playgroud)

获得的结果:

public class MyClass
{
    private int _myNewProperty; // <- Backing field …
Run Code Online (Sandbox Code Playgroud)

c# visual-studio-2010 resharper-7.1

23
推荐指数
1
解决办法
2379
查看次数

标签 统计

c# ×1

resharper-7.1 ×1

visual-studio-2010 ×1