Last active
February 5, 2019 23:21
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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