C# | Finding the index of first element in the array Last Updated : 01 Feb, 2019 Comments Improve Suggest changes Like Article Like Report GetLowerBound() Method is used to find the index of the first element of the specified dimension in the array. Syntax: public int GetLowerBound (int dimension); Here, dimension is a zero-based dimension of the array whose lower bound needs to be determined. Return Value: The return type of this method is System.Int32. This method returns the index of the first element of the specified dimension in the array. Exception: This method will give IndexOutOfRangeException if the value of dimension is less than zero, or equal or greater than Rank. Note: GetLowerBound(0) returns the starting index of the first dimension of the array, and GetLowerBound(Rank - 1) returns the starting index of the last dimension of the array. The GetLowerBound method always returns a value that indicates the index of the lower bound of the array, even if the array is empty. This method is an O(1) operation. Below programs illustrate the use of GetLowerBound() Method: Example 1: CSharp // C# program to illustrate the GetLowerBound(Int32) // method in 1-D array using System; public class GFG { // Main method static public void Main() { // 1-D Array int[] value = {1, 2, 3, 4, 5, 6, 7}; // Get the index of the first element // in the given Array by using // GetLowerBound(Int32) method int myvalue = value.GetLowerBound(0); Console.WriteLine("Index: {0}", myvalue); } } Output: Index: 0 Example 2: CSharp // C# program to illustrate the GetLowerBound(Int32) // method when the array is empty using System; public class GFG { // Main method static public void Main() { // Empty 1-D Array int[] value = {}; // Get the index of the first element // in the given Array by using // GetLowerBound(Int32) method int myvalue = value.GetLowerBound(0); Console.WriteLine("Index: {0}", myvalue); } } Output: Index: 0 Reference: https://docs.microsoft.com/en-us/dotnet/api/system.array.getlowerbound?view=netcore-2.1 Comment More infoAdvertise with us Next Article C# | Finding the index of first element in the array K Kirti_Mangal Follow Improve Article Tags : C# CSharp-Arrays CSharp-method Similar Reads C# | Finding the index of last element in the array GetUpperBound() Method is used to find the index of the last element of the specified dimension in the array. Syntax: public int GetUpperBound (int dimension); Here, dimension is a zero-based dimension of the array whose upper bound needs to be determined. Return Value:The return type of this method 2 min read C# | Array.LastIndexOf<T>(T[], T) Method Array.LastIndexOf<T>(T[], T) Method is used to search for the specified object. It returns the index of the last occurrence within the entire Array. Syntax: public static int LastIndexOf<T>(T[] array, T value); Parameters: array: It is a one-dimensional, zero-indexed array to search. val 2 min read C# | Array.Find() Method This method is used to search for an element that matches the conditions defined by the specified predicate and returns the first occurrence within the entire Array. Syntax: public static T Find (T[] array, Predicate<T> match); Here, T is the type of element of the array. Parameters: array: It 3 min read C# | Array.BinarySearch(Array, Int32, Int32, Object, IComparer) Method This method searches for an element which is in a one-dimensional sorted array within a range of elements using a specified IComparer interface. Syntax: public static int BinarySearch(Array arr, int index, int length, Object value, IComparer comparer) Parameters: arr : The sorted one-dimensional Arr 4 min read C# | Array.BinarySearch(Array, Object, IComparer) Method This method searches for a value in a one-dimensional sorted array using a specified IComparer interface. Syntax: public static int BinarySearch(Array arr, Object val, IComparer comparer) Parameters: arr : The one-dimensional sorted array in which the search will happen. val : The object value which 4 min read C# Arrays An array is a group of like-typed variables that are referred to by a common name. And each data item is called an element of the array. The data types of the elements may be any valid data type like char, int, float, etc. and the elements are stored in a contiguous location. Length of the array spe 8 min read C++ Program to Find Index of First Occurrence of a Value in Array In C++, an array is a data structure that stores elements of the same type in contiguous memory locations. In this article, we will learn how to find the index of the first occurrence of a specific value in an array in C++. Example: Input: int arr[] = {5, 7, 1, 2, 3, 7, 1} Target = 1Output: The firs 2 min read One Dimensional Arrays in C In C, an array is a collection of elements of the same type stored in contiguous memory locations. This organization allows efficient access to elements using their index. Arrays can also be of different types depending upon the direction/dimension they can store the elements. It can be 1D, 2D, 3D, 5 min read Find the index of first 1 in a sorted array of 0's and 1's Given a sorted array consisting 0's and 1's. The problem is to find the index of first '1' in the sorted array. It could be possible that the array consists of only 0's or only 1's. If 1's are not present in the array then print "-1". Examples : Input : arr[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 1}Output : 15 min read How to Initialize Array to 0 in C? Initializing an array to zero is a common practice in programming to ensure that all elements start with a known value. In C, there are several ways to initialize an array to zero. In this article, we will explore different methods to do so. Initialize Array to 0 in CThere are mainly two ways to ini 2 min read Like