EN
C# / .NET - get array length
0 points
In this article, we would like to show you how to get array length in C#.
Quick solution:
xxxxxxxxxx
1
string[] words = { "word1", "word2", "word3"};
2
3
Console.WriteLine(words.Length); // Output: 3
In this example, we use array.length
to get the length of the array.
xxxxxxxxxx
1
using System;
2
3
public class TestClass
4
{
5
public static void Main()
6
{
7
string[] words = { "word1", "word2", "word3" };
8
9
Console.WriteLine("Length of the array = " + words.Length);
10
}
11
}
Output:
xxxxxxxxxx
1
Length of the array = 3