배열에서 첫 번째 요소의 인덱스를 찾으려면 코드는 다음과 같습니다. -
예
using System; public class Demo { public static void Main() { string[] products = new string[] { "Andy", "Mark", "Gary", "Andre"}; Console.WriteLine("One or more name begin with 'A'? = {0}", Array.Exists(products, ele => ele.StartsWith("A"))); Console.WriteLine("Is the array having fixed size? = " + products.IsFixedSize); Console.WriteLine("Is the array read only? = " + products.IsReadOnly); Console.WriteLine("Is the array synchronized? = " + products.IsSynchronized); Console.WriteLine("Index of the 1st element = "+products.GetLowerBound(0)); } }
출력
이것은 다음과 같은 출력을 생성합니다 -
One or more name begin with 'A'? = True Is the array having fixed size? = True Is the array read only? = False Is the array synchronized? = False Index of the 1st element = 0
예
다른 예를 살펴보겠습니다 -
using System; public class Demo { public static void Main() { string[] products = new string[] { }; Console.WriteLine("Is the array having fixed size? = " + products.IsFixedSize); Console.WriteLine("Is the array read only? = " + products.IsReadOnly); Console.WriteLine("Is the array synchronized? = " + products.IsSynchronized); Console.WriteLine("Index of the 1st element = "+products.GetLowerBound(0)); } }
출력
이것은 다음과 같은 출력을 생성합니다 -
Is the array having fixed size? = True Is the array read only? = False Is the array synchronized? = False Index of the 1st element = 0