This file contains hidden or 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
| public string GeraSenhaAleatoria(int tamanhoSenha) | |
| { | |
| char[] possiveisCaracteres = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$&".ToArray(); | |
| // criar um IEnumerable<bool> com o total de itens definido tamanhoSenha | |
| string senha = Enumerable.Repeat(true, tamanhoSenha) | |
| // Seleciona, randomicamente, alguns caracteres e retorna um IEnumerable<char> com caracteres aleatórios | |
| .Select(c => possiveisCaracteres[rnd.Next(possiveisCaracteres.Length)]) | |
| // Junta todos os caracteres em uma única string | |
| .Aggregate(String.Empty, (current, next) => current.ToString() + next.ToString()); |
This file contains hidden or 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
| public List<object> TentaConverterListaDeStringParaObjeto(List<string> listaDeStrings) | |
| { | |
| // Não vai compilar | |
| return (List<object>)listaDeStrings; | |
| } | |
| public List<string> TentaConverterListaDeObjetoParaString(List<object> listaDeObjetos) | |
| { | |
| // Não vai compilar |
This file contains hidden or 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
| private List<string> nomeFuncionariosSede = new List<string>(){ "Uilque", "Lucas", "Luiz", "João" }; | |
| private List<string> nomeFuncionariosFiliais = new List<string>(){ "Maria", "Paula", "Pedro", "Antõnio"}; | |
| public void IterarEmDuasListasDoMesmoTipoComForeach() | |
| { | |
| foreach(string funcionario in nomeFuncionariosSede) | |
| { | |
| Console.WriteLine(funcionario); | |
| } | |
This file contains hidden or 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
| public int[] novoArrayComItensRepetidos(int itemARepetir, int totalItens) | |
| { | |
| return Enumerable.Repeat(itemARepetir, totalItens).ToArray(); | |
| } | |
| public int[] novoArraySequencial(int ultimoValor) | |
| { | |
| return Enumerable.Range(1, ultimoValor).ToArray(); | |
| } |
This file contains hidden or 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
| private IEnumerable<string> nomes = new List<string>(){ "Uilque", "Lucas", "Luiz", "João", "Pedro", "Antônio" }; | |
| public IEnumerable<string> NomesGrandesEmCaixaAltaOrdenados() | |
| { | |
| var nomesGrandesEmCaixaAlta = from n in nomes | |
| orderby n | |
| where n.Length > 5 | |
| select n.ToUpper(); | |
| return nomesGrandesEmCaixaAlta; | |
| } |
This file contains hidden or 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
| void Main() | |
| { | |
| Console.WriteLine("Digite um número que represente A:"); | |
| string aString = Console.ReadLine(); | |
| Console.WriteLine("Digite um número que represente B:"); | |
| string bString = Console.ReadLine(); | |
| float a, b; | |
| a = float.Parse(aString); |
This file contains hidden or 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
| private IEnumerable<string> nomes = new List<string>(){ "Uilque", "Lucas", "Luiz", "João", "Pedro", "Antônio" }; | |
| public IEnumerable<string> NomesGrandesEmCaixaAltaOrdenados1() | |
| { | |
| var nomesGrandesEmCaixaAlta = from n in nomes.Where(n => n.Length > 5) | |
| orderby n | |
| select n.ToUpper(); | |
| return nomesGrandesEmCaixaAlta; | |
| } |
This file contains hidden or 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
| private IEnumerable<string> nomes = new List<string>(){ "Uilque", "Lucas", "Luiz", "João", "Pedro", "Antônio" }; | |
| public IEnumerable<string> NomesGrandesEmCaixaAltaOrdenados() | |
| { | |
| var nomesGrandesEmCaixaAlta = nomes.Where(n => n.Length > 5) | |
| .OrderBy(n => n) | |
| .Select(n => n.ToUpper()); | |
| return nomesGrandesEmCaixaAlta; | |
| } |
This file contains hidden or 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
| void Main() | |
| { | |
| FormasGeometricas[] formas = new FormasGeometricas[2]; | |
| formas[0] = new Quadrado(3); | |
| formas[1] = new Retangulo(2, 4); | |
| for(int i = 0;i < formas.Length;i++) | |
| { | |
| Console.WriteLine(formas[i].Area()); | |
| } |
This file contains hidden or 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
| const replaceAtRouteName = (state, routeName, route) => { | |
| if (!route || !routeName || !state.routes) { | |
| return state | |
| } | |
| const newState = { ...state } | |
| let replaced = false | |
| state.routes.forEach((value, index) => { | |
| let replacedRoute = value |
OlderNewer