Finding the Maximum Length of Lists in C#
After I Have Created a List and Added the Contents to It, How Can I Find the Length of the List? 6 Answers Try This: Int32 Length = yourList. Count; in C#...
After I have created a list and added the contents to it, how can I find the length of the list?
6 Answers
Try this:
Int32 length = yourList.Count;
In C#, arrays have a Length property, anything implementing IList<T> (including List<T>) will have a Count property.
Example:
List<string> A = new List<string>();
int Length_A = A.Count;
You look to property size, then property length. But in c# its Count
Example: Let we are creating a List with some string named vec. Then Add 3 string and see the size using vec.Count.
List<string> vec = new List<string>();
vec.Add("Md.");
vec.Add("Ahsan");
vec.Add("Habib");
Console.WriteLine(vec.Count);
You look to property size, then property length. But in c# its Count
myList.ToArray().Length