相关疑难解决方法(0)

字段和属性之间有什么区别?

在C#中,是什么使字段与属性不同,何时应该使用字段而不是属性?

c# field properties

1032
推荐指数
17
解决办法
42万
查看次数

Lambda for getter和setter of property

在C#6.0中我可以写:

public int Prop => 777;
Run Code Online (Sandbox Code Playgroud)

但我想使用getter和setter.有办法做下一件事吗?

public int Prop {
   get => propVar;
   set => propVar = value;
}
Run Code Online (Sandbox Code Playgroud)

c# c#-6.0

46
推荐指数
2
解决办法
6万
查看次数

标签 统计

c# ×2

c#-6.0 ×1

field ×1

properties ×1