Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created October 10, 2023 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BMU-Verlag/173fe99a62a505387e1f5195c1d11559 to your computer and use it in GitHub Desktop.
Save BMU-Verlag/173fe99a62a505387e1f5195c1d11559 to your computer and use it in GitHub Desktop.
using System;
using System.Linq;
using System.Collections.Generic;
class Program {
static void Main() {
List<int> zahlen = new List<int> { 1, 2, 3, 4, 5 };
var gefilterteZahlen = from zahl in zahlen
where zahl % 2 == 0
select zahl;
Console.Write("Gerade Zahlen: ");
foreach (var zahl in gefilterteZahlen) {
Console.Write(zahl + " ");
}
// Ausgabe: Gerade Zahlen: 2 4
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment