使用 LinqPad 将字符串转换为 Guid
当我在 LinqPad 中运行以下命令时,
var ProductIds = from p in Products
where p.Id = "F1FE990C-4525-4BFE-9E2C-A7AFFF0DDA1F"
select p;
ProductIds.Dump();
它给了我
无法将类型“string”隐式转换为“System.Guid”
我只是不知道如何将其正确转换为 GUId 我猜
When I run following in the LinqPad
var ProductIds = from p in Products
where p.Id = "F1FE990C-4525-4BFE-9E2C-A7AFFF0DDA1F"
select p;
ProductIds.Dump();
it gives me
Cannot implicitly convert type 'string' to 'System.Guid'
I just don't know how to apply proper cast it to GUid I guess
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试使用
Guid.Parse(string guid)
静态方法。Try using the
Guid.Parse(string guid)
static method.您当前有一个作业,但您想使用比较 - 使用
==
而不是=
:You currently have an assignment, but you want to use a comparison - use
==
instead of=
:你不能投射它,你必须像这样解析它:
You cannot cast it, you have to parse it like that:
方法设置变量:
您还可以使用以下
You can also set a variable using:
Then