i hope i did’t make any clone.
I am studying book effective c# wrote by Bill Wagner and stuck with using query syntax.
In my project i use something like that:
this.processList = new List<Process>();
foreach (Process process in Process.GetProcesses(machine))
{
if (process.MainWindowTitle.Contains(patternTitle))
{
this.processList.Add(process);
}
}
if (processList.Count == 1)
{
this.handler = this.processList[0].MainWindowHandle;
}
And i would like to use query syntax but i really don’t have any idea how to.
I tried this under, but it fails. I know it won’t work, but this is my proof that i tried.
(from n in Enumerable.Range(0,
Process.GetProcesses(machine)).Contains select
var).add(value));
Any help will be appreciate.
P.S. please correct my topic if it was not good specified. Thanks!
If you’re trying to use LINQ be sure to include a “using System.LINQ;”
The LINQ expression you probably want is something like this:
There’s lots of examples for LINQ around. I use http://en.wikipedia.org/wiki/Linq as a reference.