-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathIndexOutofRange.cs
More file actions
36 lines (36 loc) · 844 Bytes
/
IndexOutofRange.cs
File metadata and controls
36 lines (36 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace differnce
{
class arrayoutofindex
{
public void calculatedifference()
{
int difference=0;
int [] number= new int[5] {1,2,3,4,5};
try
{
for (int init =1; init <=5; init++)
{
difference= difference - number[init];
}
Console.WriteLine("The difference of the array is:" + difference);
}
catch (IndexOutOfRangeException e)
{
Console.WriteLine(e.Message);
}
}
}
class classmain
{
static void Main(string [] args)
{
arrayoutofindex obj = new arrayoutofindex();
obj.calculatedifference();
Console.ReadLine();
}
}
}