El método Array.GetLongLength(Int32) se usa para obtener un número entero de 64 bits que representa la cantidad de elementos en la dimensión especificada de la array.
Sintaxis:
public long GetLongLength (int dimension);
Aquí, la dimensión es la dimensión de base cero de la array cuya longitud se va a calcular.
Valor devuelto: Devuelve un 64-bit
número entero que representa el número de elementos en la dimensión especificada.
Excepción: este método arroja una excepción IndexOutOfRangeException si la dimensión es menor que cero o mayor o igual que Rank .
Ejemplo:
// C# program to illustrate the // Array.GetLongLength() method using System; namespace geeksforgeeks { class GFG { // Main Method public static void Main() { // Three-dimensional array. int[,, ] arr = new int[,, ] { { { 1, 2, 3 }, { 4, 5, 6 }, { 6, 7, 8 } }, { { 11, 12, 13 }, { 14, 15, 16 }, { 17, 18, 19 } }, { { 21, 22, 23 }, { 24, 25, 26 }, { 27, 28, 29 } }, }; Console.Write("Total Number of Elements in" + " first dimension of arr: "); // using GetLongLength Method Console.Write(arr.GetLongLength(0)); // getting the type of returned value Console.WriteLine("\nType of returned Length: " + (arr.GetLongLength(0)).GetType()); // showing difference between GetLength // and GetLongLength method by getting // the type of the both method's // returned value Console.Write("\nTotal Number of Elements in " + "second dimension of arr: "); // using GetLength Method Console.Write(arr.GetLength(1)); // getting the type of returned value Console.WriteLine("\nType of returned Length: " + (arr.GetLength(1)).GetType()); Console.Write("\nTotal Number of Elements in " + "second dimension of arr: "); // using GetLongLength() Method Console.Write(arr.GetLongLength(1)); // getting the type of returned value Console.WriteLine("\nType of returned Length: " + (arr.GetLongLength(1)).GetType()); } } }
Total Number of Elements in first dimension of arr: 3 Type of returned Length: System.Int64 Total Number of Elements in second dimension of arr: 3 Type of returned Length: System.Int32 Total Number of Elements in second dimension of arr: 3 Type of returned Length: System.Int64
Nota: En el programa anterior, el tipo de retorno del método GetLength es System.Int32
pero el tipo de retorno del método GetLongLength es System.Int64
.
Referencia:
Publicación traducida automáticamente
Artículo escrito por Kirti_Mangal y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA