C#6.0 Expression-bodied 函数成员

你编写的许多成员是可以作为单个表达式的单个语句。 改为编写 expression-bodied 成员。 这适用于方法和只读属性。

    public class WeatherForecast
    {
        public DateTime Date { get; set; }

        public int TemperatureC { get; set; } = 1;

        public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);

        public string Summary { get; set; } = $"dd{(1>2?"1":"2")}g";
    }

 

posted @ 2020-09-20 13:52  竹林听雨行  阅读(416)  评论(0编辑  收藏  举报