- 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 _);
推薦閱讀
- Python數據可視化:基于Bokeh的可視化繪圖
- 深入淺出WPF
- Flash CS6中文版應用教程(第三版)
- NoSQL數據庫原理
- 軟件測試實用教程
- 智能手機故障檢測與維修從入門到精通
- Getting Started with Python
- 小程序從0到1:微信全棧工程師一本通
- 零基礎學HTML+CSS
- HTML+CSS+JavaScript網頁制作:從入門到精通(第4版)
- 從零開始:C語言快速入門教程
- Oracle Database XE 11gR2 Jump Start Guide
- Ionic3與CodePush初探:支持跨平臺與熱更新的App開發技術
- Python人工智能項目實戰
- 計算機常用算法與程序設計教程(第2版)