Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

259
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda