Hasan Akpürüm
blog-post-1

Linq Reverse

public void Linq39() {
    string[] digits = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine" };

    var reversedIDigits = (
        from digit in digits
        where digit[1] == 'i'
        select digit)
        .Reverse();

    Console.WriteLine("A backwards list of the digits with a second character of 'i':");
    foreach (var d in reversedIDigits) {
        Console.WriteLine(d);
    }
}
Sonuç : Sadece ikinci harfi 'i' olanları çekmiş olduk.
A backwards list of the digits with a second character of 'i':
nine
eight
six
five

Yorum Yaz