- C# 7 and .NET Core 2.0 High Performance
- Ovais Mehboob Ahmed Khan
- 144字
- 2021-08-27 18:47:11
Out variables
With C# 7.0, we can write cleaner code when using out variables. As we know, to use out variables, we have to first declare them. With the new language enhancement, we can now just write out as a prefix and specify the name of the variable that we need that value to be assigned to.
To clarify this concept, we will first see the traditional approach, which is shown as follows:
public void GetPerson() { int year; int month; int day; GetPersonDOB(out year, out month, out day); } public void GetPersonDOB(out int year, out int month, out int day ) { year = 1980; month = 11; day = 3; }
And here with C# 7.0, we can simplify the preceding GetPerson method, which is shown as follows:
public void GetPerson() { GetPersonDOB(out int year, out int month, out int day); }
推薦閱讀
- 有趣的二進(jìn)制:軟件安全與逆向分析
- 從0到1:數(shù)據(jù)分析師養(yǎng)成寶典
- Access 2007數(shù)據(jù)庫(kù)應(yīng)用上機(jī)指導(dǎo)與練習(xí)
- Spark核心技術(shù)與高級(jí)應(yīng)用
- 辦公應(yīng)用與計(jì)算思維案例教程
- 云數(shù)據(jù)中心網(wǎng)絡(luò)與SDN:技術(shù)架構(gòu)與實(shí)現(xiàn)
- Hadoop大數(shù)據(jù)開發(fā)案例教程與項(xiàng)目實(shí)戰(zhàn)(在線實(shí)驗(yàn)+在線自測(cè))
- MySQL技術(shù)內(nèi)幕:SQL編程
- SIEMENS數(shù)控技術(shù)應(yīng)用工程師:SINUMERIK 840D-810D數(shù)控系統(tǒng)功能應(yīng)用與維修調(diào)整教程
- 企業(yè)級(jí)大數(shù)據(jù)項(xiàng)目實(shí)戰(zhàn):用戶搜索行為分析系統(tǒng)從0到1
- 大數(shù)據(jù)計(jì)算系統(tǒng)原理、技術(shù)與應(yīng)用
- 數(shù)據(jù)會(huì)說話:活用數(shù)據(jù)表達(dá)、說服與決策
- 大數(shù)據(jù)用戶行為畫像分析實(shí)操指南
- 算法設(shè)計(jì)與問題求解(第2版):計(jì)算思維培養(yǎng)
- Reactive Programming in Kotlin