C# error CS1061: Type `System.Collections.Generic.List<int>' does not contain a definition for `Length'
13,726
There is no Length
property on List<T>
. Use Count
instead and for other classes that implement ICollection
.
Length
is typically only for arrays.
Author by
Andrew1996
Updated on June 04, 2022Comments
-
Andrew1996 almost 2 years
I'm programming in C# and I keep getting the error: "error CS1061: Type
System.Collections.Generic.List<int>' does not contain a definition for
Length' and no extension methodLength' of type
System.Collections.Generic.List' could be found. Are you missing an assembly reference?:I've added using System.Linq aswell, which was a solution to a number of similar problems however it still doesn't work.
Dictionary<string, int> decryptedPossibilites = new Dictionary<string, int>(); foreach(KeyValuePair<string, int> entry in decryptedPossibilites){ int eCount = entry.Key.Split('E').Length - 1; eCountList.Add(eCount); } int temp = 0; for (int write = 0; write < eCountList.Length; write++){ for (int sort = 0; sort < eCountList.Length - 1; sort++){ if (eCountList[sort] > eCountList[sort + 1]){ temp = eCountList[sort + 1]; eCountList[sort + 1] = eCountList[sort]; eCountList[sort] = temp; } } } foreach(int q in eCountList){ Console.WriteLine(q); }
How can I fix this?
-
Andrew1996 over 8 yearsAhh it was so easy! Thanks so much!