c# lsit size code example

Example 1: c sharp list length

// To get the length of a List use 'List<T>.Count'
List<string> stringList = new List<string>{"string1", "string2"};
stringList.Count
// Output:
// 2

Example 2: c# list length

//the using that need with list
using System;
using System.Collections.Generic;

//create List
List<int> list = new List<int>() {7,5,1,4 };
//set the length of the list to variable
int listLenght = list.Count;
//print length of the list
Console.WriteLine(listLenght);