Hi..all
I am developing a login form with User ID. I want the user to create the userid in a specified format. I need a method using C# to convert all lowercase letters to uppercase. The userid will be in the following fomat. The format is:
xyz\t4z4567 (characters are not case sensitive)
Rules:
1.Only special character \ is allowed while creating user name. 2.The UserID sholud be converted to uppercase.like (xyz --> XYZ) I need to check if user enters any special characters while creating the userid. If any special charcters are there in UserID the method needshold remove the special characters and should convert all lowercase to uppercase lettrs.
finally the result should be in the following way :
xyz\t4z45@67 ---> XYZ\T4Z4567
I used the following method to check whether the string contains the following characters and if so i am replacing with empty.
public string RemoveSpecialChars(string str) { string[] chars = new string[] { ",", ".", "/", "!", "@", "#", "$", "%", "^", "&", "*", "'", ";", "-", "_", "(", ")", ":", "|", "[", "]" }; for (int i = 0; i < chars.Length; i++) { if (str.Contains(chars[i])) { str = str.Replace(chars[i], ""); } } return str; }