Question
Find the five errors in the below code segment and rectify them 1. class SubscriptValidation 2. { 3. static void main() 4. { 5. int[]
Find the five errors in the below code segment and rectify them
1. class SubscriptValidation
2. {
3. static void main()
4. {
5. int[] array = ( 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 );
6. int sub;
7. const int QUIT = 99;
8. Console.Write("Enter a subscript value or {0} to quit >> ", QUIT);
9. sub = Convert(Console.ReadLine());
10. while (sub != QUIT)
11. {
12. Try
13. {
14. Console.WriteLine("The value is {0}", array[sub]);
15. }
16. catch (IndexOutOfRangeException e)
17. {
18. Console.WriteLine(e.Message);
19. }
20. Console.Write("Enter a subscript value or {0} to quit >> " QUIT);
21. sub = Convert.ToInt32(Console.ReadLine());
22. }
23. }
24. }
....
C# answer asap please!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started