I am reading a collection of strings (of GUID format) from excel and want to store them in database as collection of GUIDs. I am just wondering is there any clean way to convert List<string> to List<Guid> using Linq. I am not interested in looping through.
collection of strings (of GUID format)
excel
collection of GUIDs
List<string>
List<Guid>
Linq
Either LINQ:
List<Guid> guids = guidStrings.Select(Guid.Parse).ToList();
or List.ConvertAll which is a little bit more efficient because it knows the size:
List.ConvertAll
List<Guid> guids = guidStrings.ConvertAll(Guid.Parse);
1.4m articles
1.4m replys
5 comments
57.0k users