[英]Convert Linq to code using ReSharper
I have installed ReSharper 8.2.1 Full on my Visual Studio 2010 Pro and I have a requirement to convert the Linq to foreach.我已经在我的 Visual Studio 2010 Pro 上安装了 ReSharper 8.2.1 Full,我需要将 Linq 转换为 foreach。 I found this article on their help site which tells like Converting a linq expression to code is possible with Resharper.
我在他们的帮助站点上找到了这篇文章,其中讲述了使用 Resharper 可以将 linq 表达式转换为代码。
when I opened my application in Visual Studio and Placed the caret at the query expression and pressed Alt+Enter, I can see the "Convert Linq to method chain" but the other option "Convert Linq to code" is missing .当我在 Visual Studio 中打开我的应用程序并将插入符放在查询表达式上并按 Alt+Enter 时,我可以看到“将 Linq 转换为方法链”,但缺少另一个选项“将 Linq 转换为代码” 。 Do I need to add any settings to make it work?
我是否需要添加任何设置才能使其正常工作? Have anyone tried this option?
有人试过这个选项吗?
"Convert LINQ to code" only works with certain expression patterns, like a foreach
statement or a return
statement that can be converted into a loop with yield return
. “将LINQ转换为代码”仅适用于某些表达式模式,如
foreach
语句或return
语句,可以转换为带有yield return
的循环。 What's your code block? 你的代码块是什么?
var data = lines
.Skip(1)
.Select(p=>p.Split(','))
.GroupBy(p=>p[0])
.Select((p,i)=>new Datastore.QuizCategory{
Id = i+1,
Name = p.Key,
QuizQuestions = p.Select(pp=>new QuizQuestion{
Question = pp[1],
Options = pp[2].Replace("\uff1b", ";").Split(";"),
Answers = pp[3].Replace("\uff1b", ";").Split(";")
.Where(p=>string.IsNullOrEmpty(p)==false)
.Select(ppp=>int.Parse(ppp))
.ToArray()
}).ToArray()
}).ToArray();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.