关于类属性的入门级问题

来源:百度知道 编辑:UC知道 时间:2024/06/15 01:01:50
这种属性写法我看不懂,请高手解释下,谢谢了!

public class CReportHeadAttribute

{
protected int _BackColor;
protected string _ColumnField;
protected string _Font;
protected int _FontColor;
protected byte _FontSize;
protected int _FontStyle;
protected byte _FrameStyle;
protected string _Function;
protected int _MergeColumns;
protected int _MergeRows;
protected CReport _Report;
protected int _RowID;
protected string _ShowName;
protected int _Size;
protected byte _SpecialMark;
protected int _TextAlign;

public CReportHeadAttribute();

public int BackColor { get; }
public string ColumnField { get; }
public string Font { get; }
public int FontColor { get; }
public byte FontSize { get; }

C# 3.0 里面有新的的新属性写法了,这种写法下属性不用再写局部变量了,而只要这样写:
public int Property1 {get;set;}
就可以了,编译的时候编译器会代为生成隐藏的局部变量。

但是看楼主的代码不合规范,可能是 abstarct 类(必须继承的)

同意楼上 这不是抽象类或是接口,
所以必须要有主体,只定义是不行的!我也刚学 ,不太懂