-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Beginning C# 7 Hands-On ??? Advanced Language Features
By :
In the first stage, you have to add delegates. While you could put these into a separate file, for our purposes let's just place them here. So, enter the following above the line beginning with public partial class...:
public delegate bool Compare(double x, double y);
Remember, delegates are function or method wrappers, actually. Then, directly below this line, enter the following:
public delegate double Multiply(double x, double y);
You can see here that we have two delegates. One returns a Boolean data type, and the other one returns a double data type.
Next, inside the event handler for Button1_Click, we'll make two variables: x (which we set to 10), and y, which equals 25. So, enter the following between the set of curly braces:
double x = 10, y = 25;
Now, the next thing that we will do is to enter the following below the preceding line:
Compare comp = (a, b) => (a == b);
As you begin to enter Compare, notice from...