将字符串集合转换为 GUID 集合

Ven*_*nky -2 c# linq excel guid

我正在读取collection of strings (of GUID format)来自excel并希望将它们存储在数据库中作为collection of GUIDs. 我只是想知道是否有任何干净的方法可以转换List<string>List<Guid>使用Linq. 我对循环遍历不感兴趣。

Tim*_*ter 5

要么 LINQ:

List<Guid> guids = guidStrings.Select(Guid.Parse).ToList();
Run Code Online (Sandbox Code Playgroud)

或者List.ConvertAll哪个更有效,因为它知道大小:

List<Guid> guids = guidStrings.ConvertAll(Guid.Parse);
Run Code Online (Sandbox Code Playgroud)