Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
Convert elements in List<string> to List<Texture> in C# (Unity3d)

How should I best go about converting the elements of

List<string> icons

to:

List<Texture> icons

I'm pulling filenames from an XML file (thus the initial string format) but I want to convert the filenames to texture format because they are dynamically formed at runtime so I can't load from the inspector.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use ConvertAll<T>

icons.ConvertAll<Texture>(s => new Texture(..whatever conversion...))

or you can use LINQ to transform

from s in icons select new Texture(...)

both prety much boil down to the same. Difference is that LINQ gives you an IEnumerable that pools data directly from string list (without creating a new list) so its good for once-off uses. If you need a persisten list of Textures either use ConvertAll or pin down the IEnumerable using ToList()

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!