官术网_书友最值得收藏!

Out variables

If you want to pass parameters to a method for modification, then you always need to declare them first. This is no longer necessary, and you can simply declare the variables at the point you pass them in. You can also declare a variable to be discarded, using an underscore. This is particularly useful if you don't want to use the returned value, for example, in some of the try parse methods of the native framework data types.

Here, we parse a date without declaring the dt variable first:

DateTime.TryParse("2017-08-09", out var dt);

In this example, we test for an integer, but we don't care what it is:

var isInt = int.TryParse("w00t", out _);
主站蜘蛛池模板: 田东县| 绥化市| 大方县| 阜阳市| 辉县市| 抚松县| 德化县| 新巴尔虎左旗| 年辖:市辖区| 鄂州市| 本溪| 厦门市| 沧源| 永靖县| 蓝山县| 桑日县| 长阳| 沅陵县| 高尔夫| 县级市| 阿瓦提县| 盐津县| 池州市| 山东| 石门县| 峨山| 宁化县| 泸西县| 昌乐县| 庄浪县| 五寨县| 海安县| 兴国县| 定日县| 汽车| 民乐县| 枞阳县| 措美县| 白水县| 阿克陶县| 蛟河市|