- ASP.NET Core 2 High Performance(Second Edition)
- James Singleton
- 116字
- 2021-07-08 09:38:59
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 _);
推薦閱讀
- PHP動態(tài)網(wǎng)站程序設(shè)計
- Facebook Application Development with Graph API Cookbook
- 算法精粹:經(jīng)典計算機科學(xué)問題的Java實現(xiàn)
- Java FX應(yīng)用開發(fā)教程
- Learning Apache Mahout Classification
- Python Data Analysis Cookbook
- Hands-On Full Stack Development with Spring Boot 2.0 and React
- Java 從入門到項目實踐(超值版)
- C編程技巧:117個問題解決方案示例
- Python數(shù)據(jù)可視化之美:專業(yè)圖表繪制指南(全彩)
- Unity 2017 Game AI Programming(Third Edition)
- 算法圖解
- Maven for Eclipse
- Web開發(fā)的平民英雄:PHP+MySQL
- Python 快速入門(第3版)