using System.Collections.Generic;
public static void Main()
private static void wrongMethod()
var inputList = new List<int> { 15, 24, 11, 22, 10, 12 };
for (int i = 0; i < inputList.Count; i++)
if (inputList[i] % 11 == 0)
foreach (var element in inputList)
Console.Write(element + " ");
private static void rightMethod()
var filteredList = new List<int>();
var inputList = new List<int> { 15, 24, 11, 22, 10, 12 };
for (int i = 0; i < inputList.Count; i++)
if (inputList[i] % 11 != 0)
filteredList.Add(inputList[i]);
foreach (var element in filteredList)
Console.Write(element + " ");
private static void anotherMethod()
var inputList = new List<int> { 15, 24, 11, 22, 10, 12 };
foreach (var element in inputList.Where(x => x % 11 != 0))
Console.Write(element + " ");