- Beginning C# 7 Hands-On:Advanced Language Features
- Tom Owsiak
- 118字
- 2021-07-02 15:29:14
Initializing a collection of integers to their array and displaying the results
Now, double-click on the Display Values button and go into Default.aspx.cs. Delete the Page_Load block. Next, between the set of curly braces beneath the line beginning with protected void Button1_Click..., enter the following:
GenericsClass<int> ints = new GenericsClass<int>(new int[] { 1, 2, 3, 4, 5 });
You can see in this line that we are basically initializing a collection of integers to their array.
Now, you can display this. So, for example, you can enter the following below this line:
sampLabel.Text += ints.DisplayValues();
Notice that the GenericsClass which we have constructed is operating in integers, but it can operate equally well on any other data type.
推薦閱讀
- JavaScript全程指南
- Kali Linux Web Penetration Testing Cookbook
- FreeSWITCH 1.8
- R語(yǔ)言經(jīng)典實(shí)例(原書第2版)
- Leap Motion Development Essentials
- Microsoft Dynamics 365 Extensions Cookbook
- iOS開(kāi)發(fā)實(shí)戰(zhàn):從零基礎(chǔ)到App Store上架
- Java游戲服務(wù)器架構(gòu)實(shí)戰(zhàn)
- Julia Cookbook
- Windows Phone 7.5:Building Location-aware Applications
- PHP編程基礎(chǔ)與實(shí)例教程
- Learning Python Data Visualization
- 征服C指針(第2版)
- 你必須知道的.NET(第2版)
- Building Microservices with .NET Core 2.0(Second Edition)