Answer the question
In order to leave comments, you need to log in
C#. Selecting an element from an array by name?
I have an array "All" of type Sprite containing 5 elements: "Test1.png", "Test2.png", "Test3.png", "Test4.png", "Test5.png",
Can I select an element from the array by his name?
For example:
With this approach, it gives an error that I cannot convert string to int.
All["Test3.png"];
Answer the question
In order to leave comments, you need to log in
Read about indexers https://metanit.com/sharp/tutorial/4.10.php
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question