相关疑难解决方法(0)

c#将现有类转换为正确使用属性

我有以下课程:

class Given
{
    public string text = "";
    public List<StartCondition> start_conditions = new List<StartCondition>();
};

class StartCondition
{
    public int index = 0;
    public string device = "unknown";
    public string state = "disconnected";
    public bool isPass = false;
};
Run Code Online (Sandbox Code Playgroud)

我想将它们转换为c#属性(使用get;和set;)

看看这个问题:什么是get-set-syntax-in-c,似乎我可以像这样使一个属性变得简单易行:

class Given
{
    public string text { get; set; }
    public List<StartCondition> start_conditions { get; set; }
};

class StartCondition
{
    public int index { get; set; }
    public string device { get; set; }
    public …
Run Code Online (Sandbox Code Playgroud)

c# containers properties

0
推荐指数
1
解决办法
88
查看次数

标签 统计

c# ×1

containers ×1

properties ×1