the one Posted May 21, 2009 at 11:04 AM Report #266096 Posted May 21, 2009 at 11:04 AM Bom dia a todos . Preciso de ajuda numa sugestão de utilizadores depois de inserido o nome . Queria algo deste genero : Nome : João Carlos da Silva Almeida E depois de carregar no botão para sugestão , aparecer algo do genero : Utilizador: JAlmeida Aceito sugestoes xD Obrigado
the one Posted May 21, 2009 at 11:36 AM Author Report #266101 Posted May 21, 2009 at 11:36 AM Já tenho o codigo para conseguir o primeiro caracter em maiuscula . nome = txtnome.Text; tamanho = nome.Length; char1 = nome[0]; primeira = Convert.ToString(char1); primeira = primeira.ToUpper(); MessageBox.Show(primeira); Agora a minha duvida é , como consigo contar caracteres a partir da direita , até que haja um espaco , ou seja, isto vai-me retornar o ultimo nome .
Baderous Posted May 21, 2009 at 12:36 PM Report #266119 Posted May 21, 2009 at 12:36 PM Podes usar o método Split para separar o nome por espaços e depois utilizas a última substring recolhida.
inginheiiro Posted May 21, 2009 at 12:45 PM Report #266121 Posted May 21, 2009 at 12:45 PM string a = "duMmY user nAME"; a = string.Format("{0}{1}", a.Trim()[0].ToString().ToUpper(), System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase (a.Trim().Split(' ')[a.Trim().Split(' ').Length - 1])); my 2 cents I used to have a life ... but i bought a programmable machine in 1982 ...
the one Posted May 21, 2009 at 01:18 PM Author Report #266129 Posted May 21, 2009 at 01:18 PM string a = "duMmY user nAME"; a = string.Format("{0}{1}", a.Trim()[0].ToString().ToUpper(), System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase (a.Trim().Split(' ')[a.Trim().Split(' ').Length - 1])); my 2 cents Fiz dessa maneira e funcionou perfeito mesmo . Obrigado inginheiro 😛
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now