Say I have an array with size 20. Is that array's .length
property equivalent to 20? Also is there a way in my code to convert array.length
to an integer?
Yes, you are correct. According to the MSDN docs, an array's .Length
property returns the total number of elements in all the dimensions of the array and zero if there are no elements in the array.
The .Length
property is an integer, so there's no need for any conversion. Though there's really no need to assign it because it is a constant-time operation, you could assign it like this:
int arrayLength = array.Length;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.