Useful Methods to Return values in Arrays Here are the available methods to get values in an array. Max returns the largest value. Min returns the smallest value. Sum returns the sum of all elements. Examples : Let’s consider this array : int[ ] arr = { 2, 4, 7, 1}; Console.WriteLine(arr.Max()); //Outputs :  7 Console.WriteLine(arr.Min()); //Outputs : 1Console.WriteLine(arr.Sum()); //Outputs : 14Read More →

Here lets create an array of Fruits (of same data type string) Name of Our Array is mystrArray and it has 5 elements.   string[] mystrArray = new string[] { “Apple”, “Banana”, “Grapes”, “Mango”, “Pine-Apple” };   // Reading array items using foreach loop foreach (string mystr in mystrArray) {     Console.WriteLine(mystr); } A loop will iterate through all the elements in the string and Print them one by one as we are referring to Each element of the array. Foreach loop is very handy when the requirement is to fetch multiple rows of records from a database.Read More →

C# has  various classes that are built-in and they can store and manipulate data. An example of such a class is the Array class. In order to store a collection of data the data structure that is used in C# is known as array. It can be described as a collection of variables of the same type. Let’s assume a situation where you need to store 250 numbers. One option is to declare 250 different variables but a smarter solution is to declare an array that stores 250 elements. To declare an array, specify its element types with square brackets: int[ ] yourArray; This isRead More →