Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

finding the maximum length of lists in c#

Tags:

c#

list

After I have created a list and added the contents to it, how can I find the length of the list?

like image 718
anildevkj Avatar asked Nov 08 '09 23:11

anildevkj


People also ask

How do you find the length of a list in C sharp?

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.

What are the maximum dimensions a list can have?

According to the source code, the maximum size of a list is PY_SSIZE_T_MAX/sizeof(PyObject*) . On a regular 32bit system, this is (4294967295 / 2) / 4 or 536870912.

How do I find the length of a sublist?

Using len and max In this approach, we first find the sub-list with maximum length and then loop through the elements of the list to find out which sublist match that length. We use the max and len function to do this calculation.


1 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.

like image 154
Andrew Hare Avatar answered Sep 23 '22 06:09

Andrew Hare