C# Program to find the length of an Array1 min read

In this article of C# program to find the length of an array entered by the user, we have used while loop and trycatch block for the exception

Question:
Write a C# program to find the length of an Array.

Solution:
Here first we take the arrays from the user and to exit from an array user need to enter –999 at last. -999 is an exit value that is defined at the beginning of the program.
To take the user input, while loop is used inside which try-and catch block are executed. lastly array.Length is used to get hoe many elements the user entered.


C# Program to find the length of an Array.

It can also be done without the use of try-catch block

Source Code

The Output of finding the length of the entered Array in C-sharp.

C# Program for Multilevel inheritance with Virtual Function