View linq-gera-senha-aleatoria.cs
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
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()); |
View linq-converte-lista.cs
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
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 |
View linq-iterar-em-duas-listas.cs
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
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); | |
} | |
View linq-inicializar-array.cs
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
public int[] novoArrayComItensRepetidos(int itemARepetir, int totalItens) | |
{ | |
return Enumerable.Repeat(itemARepetir, totalItens).ToArray(); | |
} | |
public int[] novoArraySequencial(int ultimoValor) | |
{ | |
return Enumerable.Range(1, ultimoValor).ToArray(); | |
} |
View linq-query-expression.cs
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
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; | |
} |
View algoritmo-csharp-soma.cs
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
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); |
View linq-query-and-fluent.cs
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
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; | |
} |
View linq-fluent-syntax.cs
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
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; | |
} |
View ToastMatcher.java
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
package br.com.uilquemessias.utils; | |
import android.os.IBinder; | |
import android.support.test.espresso.Root; | |
import android.view.WindowManager; | |
import org.androidannotations.annotations.res.StringRes; | |
import org.hamcrest.Description; | |
import org.hamcrest.Matcher; | |
import org.hamcrest.TypeSafeMatcher; |
View FormasGeometricas.cs
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
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()); | |
} |
OlderNewer