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.
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()