EN
C# / .NET - get List size
0
points
In this article, we would like to show you how to get List size in C#.
Quick solution:
List<int> myList = new List<int> { 1, 2, 3, 4 };
int size = myList.Count; // 4
Practical example
In this example, we use Count property to get the size of myList.
using System;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
List<int> myList = new List<int> { 1, 2, 3, 4 };
int size = myList.Count;
Console.WriteLine(size); // 4
}
}
Output:
4