Skip to content

Instantly share code, notes, and snippets.

@stephensmitchell
Forked from esride-apf/SimpleProgram.linq
Last active April 19, 2018 01:00
Show Gist options
  • Save stephensmitchell/2738e30c125dc8f34d8eae6a7367bed9 to your computer and use it in GitHub Desktop.
Save stephensmitchell/2738e30c125dc8f34d8eae6a7367bed9 to your computer and use it in GitHub Desktop.
LINQPad Samples #LINQPad
void Main()
{
var listOfI = GetInts();
foreach (var i in listOfI)
{
Console.WriteLine(i);
}
Console.WriteLine("******");
Console.WriteLine("jetzt 1-stellige");
var einstellige = from i in listOfI where i < 10 select i;
foreach (var i in einstellige)
{
Console.WriteLine(i);
}
Console.WriteLine("******");
Console.WriteLine("jetzt 2-stellige");
var zweistellige = listOfI.Where(i => i >= 10);
foreach (var i in zweistellige)
{
Console.WriteLine(i);
}
Console.WriteLine("******");
Console.WriteLine("und nochmal alle");
listOfI.ToList().ForEach(i => Console.WriteLine(i));
}
// Define other methods and classes here
public IEnumerable<int> GetInts()
{
Console.WriteLine("Start yielding");
yield return 1;
yield return 2;
yield return 11;
yield return 12;
Console.WriteLine("End yielding");
}
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName= "notepad.exe";
proc.Start();
proc.WaitForExit();
Console.WriteLine("Habe fertig");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment