In C#, the length of an array can be found using the .Length
property. Here's an example:
main.cs102 chars4 lines
Alternatively, you can also use the .Count()
extension method from the System.Linq
namespace:
main.cs101 chars4 lines
Note that the .Count()
method works not only for arrays but also for other enumerable collections. Another alternative is using the sizeof
operator, but this is only applicable to arrays of value types:
main.cs171 chars4 lines
gistlibby LogSnag