Making an array of points
Now, left double-click on the Make
and Show Points
button.
Start by deleting the Page_Load
block in the Event Handler. Your starting Default.aspx.cs
file should look like the one shown in the following screenshot:
Figure 6.19.5: Beginning snippet of Default.aspx.cs
Now we are going to make an array of points. So, enter the following between curly braces under the line that begins with protected void Button1_Click...
:
Point[] points = new Point[10];
Point
is the struct
array that we have made, and points
is the name of the array. Let's specify the length as [10]
in this example.
Now, you want to fill in the x
and y
coordinates of each Point
type array, so enter the following below the Point[] points = new point[10];
line:
for (int i = 0; i < points.Length; i++) //Filling the Array with New Points Whose x and y Coordinates Are Random
In the next stage, enter the following within a set of curly braces below the preceding line:
points[i] = new Point(new Random().Next(-10...