書名: 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.
推薦閱讀
- Learning Docker
- Oracle從新手到高手
- Xcode 7 Essentials(Second Edition)
- Learning Informatica PowerCenter 10.x(Second Edition)
- Learning SQLite for iOS
- Mastering Drupal 8 Views
- Getting Started with LLVM Core Libraries
- 零基礎Java學習筆記
- Advanced Express Web Application Development
- Building Microservices with .NET Core
- Microsoft 365 Certified Fundamentals MS-900 Exam Guide
- Angular應用程序開發指南
- Shopify Application Development
- Selenium WebDriver Practical Guide
- Clojure Data Structures and Algorithms Cookbook