Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Driely

Ignorar o Caso

Recommended Posts

string.Compare(valor1,valor2, StringComparison.OrdinalIgnoreCase);

se retornar 0 (zero), é igual

Compartilhar este post


Link para o post
Compartilhar em outros sites

porém esotu com problemas para entender este último parâmetro...grata :rolleyes:

hieste último parâmetro OrdinalIgnoreCase, ignora maiúsculos e minúsculos na comparação de dois valores stringse tu declarar o hashtable assim: new Hashtable(StringComparer.OrdinalIgnoreCase) não agiliza um lado pra você?

Compartilhar este post


Link para o post
Compartilhar em outros sites

ainda não está adiantando...

 

está assim meu código, considerando que minha hashtable esteja declarada como dito acima...

 


hashValores.Add("\\", "");

hashValores.Add("-", "");

hashValores.Add("_", "");

hashValores.Add("\"", "");

hashValores.Add("+", "");

hashValores.Add("?", "");

hashValores.Add("!", "");

hashValores.Add("@", "");

hashValores.Add("#", "");

hashValores.Add("$", "");

hashValores.Add("%", "");

hashValores.Add("(", "");

hashValores.Add(")", "");

hashValores.Add("|", "");

hashValores.Add("[", "");

hashValores.Add("]", "");

hashValores.Add("*", "");

hashValores.Add(".", "");

hashValores.Add(" da ", "");

hashValores.Add(" das ", "");

hashValores.Add(" do ", "");

hashValores.Add(" dos ", "");

hashValores.Add(" de ", "");

hashValores.Add(" para ", "");

hashValores.Add(" pra ", "");

hashValores.Add(" ao ", "");

hashValores.Add(" aos ", "");

hashValores.Add(" às ", "");

hashValores.Add(" a ", "");

hashValores.Add(" as ", "");

hashValores.Add(" o ", "");

hashValores.Add(" os ", "");

hashValores.Add(" em ", "");

hashValores.Add(" no ", "");

hashValores.Add(" nos ", "");

hashValores.Add(" na ", "");

hashValores.Add(" nas ", "");

hashValores.Add(" com ", "");

hashValores.Add("p/", "");

hashValores.Add("c/", "");

hashValores.Add("/", "");

hashValores.Add("ª", "");

hashValores.Add("º", "");

hashValores.Add("<", "");

hashValores.Add(">", "");

hashValores.Add(";", "");

hashValores.Add(" e ", "");

hashValores.Add(" _linenums:0'>public static String formataTexto(String texto) { if (EnumaradoHelper.hashValores == null) { EnumaradoHelper.hashValores = new Hashtable(StringComparer.OrdinalIgnoreCase); hashValores.Add("á", "a"); hashValores.Add("à", "a"); hashValores.Add("ã", "a"); hashValores.Add("â", "a"); hashValores.Add("é", "e"); hashValores.Add("ê", "e"); hashValores.Add("í", "i"); hashValores.Add("ó", "o"); hashValores.Add("õ", "o"); hashValores.Add("ô", "o"); hashValores.Add("ú", "u"); hashValores.Add("ü", "u"); hashValores.Add("ç", "c"); hashValores.Add("'", ""); hashValores.Add("\\", ""); hashValores.Add("-", ""); hashValores.Add("_", ""); hashValores.Add("\"", ""); hashValores.Add("+", ""); hashValores.Add("?", ""); hashValores.Add("!", ""); hashValores.Add("@", ""); hashValores.Add("#", ""); hashValores.Add("$", ""); hashValores.Add("%", ""); hashValores.Add("(", ""); hashValores.Add(")", ""); hashValores.Add("|", ""); hashValores.Add("[", ""); hashValores.Add("]", ""); hashValores.Add("*", ""); hashValores.Add(".", ""); hashValores.Add(" da ", ""); hashValores.Add(" das ", ""); hashValores.Add(" do ", ""); hashValores.Add(" dos ", ""); hashValores.Add(" de ", ""); hashValores.Add(" para ", ""); hashValores.Add(" pra ", ""); hashValores.Add(" ao ", ""); hashValores.Add(" aos ", ""); hashValores.Add(" às ", ""); hashValores.Add(" a ", ""); hashValores.Add(" as ", ""); hashValores.Add(" o ", ""); hashValores.Add(" os ", ""); hashValores.Add(" em ", ""); hashValores.Add(" no ", ""); hashValores.Add(" nos ", ""); hashValores.Add(" na ", ""); hashValores.Add(" nas ", ""); hashValores.Add(" com ", ""); hashValores.Add("p/", ""); hashValores.Add("c/", ""); hashValores.Add("/", ""); hashValores.Add("ª", ""); hashValores.Add("º", ""); hashValores.Add("<", ""); hashValores.Add(">", ""); hashValores.Add(";", ""); hashValores.Add(" e ", ""); hashValores.Add(":", ""); } char[] caracteres = new char[texto.Length]; caracteres = texto.ToCharArray(); int i = 0; caracteres = Char.ToUpperInvariant(caracteres); for (i = 1; i < caracteres.Length-1; i++) { if (caracteres == ' ') caracteres[i + 1] = Char.ToUpperInvariant(caracteres[i + 1]); } String aux = new String(caracteres); StringBuilder stb = new StringBuilder(aux); foreach (String key in EnumaradoHelper.hashValores.Keys) { stb.Replace(key, EnumaradoHelper.hashValores[key].ToString()); } return stb.ToString().Replace(" ", ""); }

Estou precisando que minha variável key seja trabalhada com o caso ignorado, e é isso que naum estou conseguindo...

Compartilhar este post


Link para o post
Compartilhar em outros sites

já consegui...tópico: off

legal, conta ai como tu fez?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.