Setting up the user interface
Let's begin with this very simple interface. Here's our markup, and all I have in there already is a Button
and Label
control:

Figure 5.4.1: Our simple starting user interface
In the Design
view, our interface appears as shown in the following screenshot:

Figure 5.4.2: Our interface in the Design view
Now, just double-click on the Button
control to generate the event handler so that you can write some code. When you do that, it generates the event handler as shown in the following code block:
protected void Button1_Click(object sender, EventArgs e) { }
Creating the method to find the total of values inside an array
We'll create a method right above the line beginning with protected void
. The purpose of this method will be to find the total of some values inside an array. To create the method, we'll do the following:
We saw private
, static
, and double
before. Let's name this method as Sum
. Now, because we'll accept an array, we cannot create on it. Type double
as an...