- 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.
推薦閱讀
- Spring Boot 2實(shí)戰(zhàn)之旅
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- Visual Basic .NET程序設(shè)計(jì)(第3版)
- Web前端開發(fā)技術(shù):HTML、CSS、JavaScript(第3版)
- C和C++安全編碼(原書第2版)
- Java程序設(shè)計(jì)與實(shí)踐教程(第2版)
- Eclipse Plug-in Development:Beginner's Guide(Second Edition)
- Mathematica Data Analysis
- 劍指大數(shù)據(jù):企業(yè)級(jí)數(shù)據(jù)倉庫項(xiàng)目實(shí)戰(zhàn)(在線教育版)
- Building Machine Learning Systems with Python(Second Edition)
- C++反匯編與逆向分析技術(shù)揭秘(第2版)
- Oracle GoldenGate 12c Implementer's Guide
- Java SE實(shí)踐教程
- Getting Started with Python and Raspberry Pi
- R語言數(shù)據(jù)可視化:科技圖表繪制