F
F
FireDrago192020-12-01 11:31:09
C++ / C#
FireDrago19, 2020-12-01 11:31:09

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

3 answer(s)
V
Vasily Bannikov, 2020-12-01
@FireDrago19

No. You needDictionary<string, Sprite>

V
Vladimir Korotenko, 2020-12-01
@firedragon

Read about indexers https://metanit.com/sharp/tutorial/4.10.php

V
Vitaliy, 2016-11-08
@vitstr

Taki found
www.typography.com/fonts/operator/styles

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question