+ 1

ToArray() method ??

Does the ToArray() method when used with Dictionary/ HashSet/Stack or Queue copy the list into a new array, array as in the first form of array we learned? Or.. was a little hard for me grasp

15th Dec 2022, 12:17 PM
Visual learner
Visual learner - avatar
5 Respostas
+ 2
Any Array is static array only...
15th Dec 2022, 5:02 PM
Jayakrishna 🇮🇳
+ 2
You can apply dictionary methods on dictionary. And queue methods on queue only.. Then what do you mean 'no longer'? See if q is queue, d is a dictionary then if possible you can make array like var arr = q.ToArray(); or var arr = d.keys().ToArray(); Now "arr" is an array. The q, d are still originals. You are not changed so you can apply d.Cobtains(key) ; but you cant apply arr.Contains(key) ; not valid dict method on array...
15th Dec 2022, 5:58 PM
Jayakrishna 🇮🇳
+ 1
Edit to question, would it be stored in an array of Static memory allocation or dynamic?
15th Dec 2022, 2:30 PM
Visual learner
Visual learner - avatar
+ 1
So it does no longer take in methods that are used for (example) Queues or Dictionaries .. like .ContainsKey(K key)
15th Dec 2022, 5:10 PM
Visual learner
Visual learner - avatar
+ 1
Ohhh thank you!
15th Dec 2022, 5:59 PM
Visual learner
Visual learner - avatar