C# dasturlash tili To’plamlar (Kolleksiyalar) private static void ListEvenNumbers() private static void ListEvenNumbers() { foreach (int number in EvenSequence(5, 18)) { Console.Write(number.ToString() + " "); } Console.WriteLine(); // Output: 6 8 10 12 14 16 18 } private static IEnumerable EvenSequence( int firstNumber, int lastNumber) { // diapazonda juft sonlarni chiqarish. for (var number = firstNumber; number <= lastNumber; number++) { if (number % 2 == 0) { yield return number; } } } C# dasturlash tili To’plamlar (Kolleksiyalar) E’tiboringiz ‘uchun’{ Rahmat
}
Do'stlaringiz bilan baham: |