0

How .ToArrays() works????????

https://code.sololearn.com/c7d0L2Pq1Pfd/?ref=app In this code i noticed that the program doesnt declare an array. Ex. string[] c = coffee.Keys.ToArray(); But instead it used the foreach loop even there is no declared array: foreach(string s in coffee.Keys.ToArray()); So how does the .ToArray() method transfers the Keys of the Dictionary to an array, even it doesnt declare an array?

4th Jun 2021, 1:34 PM
Xenon
Xenon - avatar
1 Respuesta
+ 1
I haven't seen the source code but ToArray method must be creating a new array with values as keys and returning that array.
4th Jun 2021, 1:58 PM
Abhay
Abhay - avatar