- 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.
推薦閱讀
- Angular UI Development with PrimeNG
- Vue.js快跑:構(gòu)建觸手可及的高性能Web應(yīng)用
- Scratch 3游戲與人工智能編程完全自學(xué)教程
- HTML5+CSS3網(wǎng)站設(shè)計(jì)基礎(chǔ)教程
- 利用Python進(jìn)行數(shù)據(jù)分析
- CoffeeScript Application Development Cookbook
- Kubernetes進(jìn)階實(shí)戰(zhàn)
- 分布式數(shù)據(jù)庫(kù)原理、架構(gòu)與實(shí)踐
- Mastering Concurrency Programming with Java 9(Second Edition)
- C++程序設(shè)計(jì)
- Python 3 Object:oriented Programming(Second Edition)
- 計(jì)算機(jī)應(yīng)用基礎(chǔ)(第二版)
- OpenCV Android開(kāi)發(fā)實(shí)戰(zhàn)
- Java程序設(shè)計(jì)教程
- Puppet Cookbook(Third Edition)