Skip to content

Instantly share code, notes, and snippets.

@jfbueno
Last active February 5, 2019 23:21
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 jfbueno/88b968c8bb86b880c92da51c4eeccbe1 to your computer and use it in GitHub Desktop.
Save jfbueno/88b968c8bb86b880c92da51c4eeccbe1 to your computer and use it in GitHub Desktop.
filtro-array-1 created by jfbueno - https://repl.it/@jfbueno/filtro-array-1
using System.Linq;
using System.Collections.Generic;
using static System.Console;
class MainClass
{
public static void Main (string[] args)
{
var numeros = Enumerable.Range(1, 31);
WriteLine("Números de 1 a 30");
foreach(var n in numeros)
WriteLine(n);
var pares = ApenasPares(numeros);
WriteLine("\nNúmeros Pares");
foreach(var n in pares)
WriteLine(n);
}
private static List<int> ApenasPares(IEnumerable<int> entrada)
{
var saida = new List<int>();
foreach(var item in entrada)
{
if(item % 2 == 0)
saida.Add(item);
}
return saida;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment