更新时间:2021-07-02 15:30:20
coverpage
Title Page
Copyright
Beginning C# 7 Hands-On – Advanced Language Features
Credits
About the Author
www.PacktPub.com
Why subscribe?
Customer Feedback
Preface
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
Creating a Simple Generics Class
Creating a generics class
Working with different data types
Making parameters that are generic
Displaying the values
Adding a button to Default.aspx
Initializing a collection of integers to their array and displaying the results
Changing the data types in our generics class
Running the program
Accumulating the input
Chapter review
Summary
Creating a Generic Method
Creating a button to exchange and then comparing two values
Writing a swap function
Comparing values using the CompareTo method
Introducing constraints
Completing the GenMethods class
Hardcoding the values
Modifying the program for an additional type of comparison
Modifying the program for different data types
Implementing a Generic Interface to Accomplish Sorting
Adding a button to sort and display results
Creating a generics interface class
Implementing the interface
Adding a virtual function
Adding refinements
Entering the reference code
Upcasting
Downcasting
Making Delegates More Flexible with Generics
Adding a summarize button to the HTML
Constructing a delegate
Assigning functions to represent the delegate
Calling the delegate
Creating and Using Generic Dictionaries
Adding a show button to the HTML
Starting a process from a web page
Making a verbatim string
Iterating over key-value pairs
Making a directory and creating a file from Command Prompt
Connection Between Delegates and Lambda Expressions
Adding a Show Results button to the HTML
Adding delegates
Setting up the variables
Making objects of the delegate type
Defining lambda expressions
Operating an array
Working with actions
Expression-Bodied Lambdas and Expression-Bodied Members
Adding a box and a Find Max button to the HTML
Making the delegate
Defining an expression-bodied member
Converting an array of strings into an array of doubles
Creating an expression-bodied lambda
Comparing values
Specifying the parameters
Anonymous Methods and Objects That Run Their Own Delegates
Streamlining writing functions
Performing an action on all of the values
Making an anonymous function or method
Starting a thread
Running and modifying the program