大写小写字母的转换

private void tolower(string test)
        {
            if (test.Length != 0)
            {
                //转换成单个字符
                char[] a = test.ToCharArray();
                for (int i = 0; i < a.Length; i++)
                {
                    //97 -122 是小写字母的范围值
                    if (Convert.ToInt32(a[i]) >= 97 && Convert.ToInt32(a[i]) <= 122)
                    {
                        MessageBox.Show("lower charcters");
                    }
                    //65 -90 是大写字母的一个范围
                    else if (Convert.ToInt32(a[i]) >= 65 && Convert.ToInt32(a[i]) <= 90)
                    {
                        MessageBox.Show(a[i].ToString().ToLower());
                    }
                    else
                    {
                        MessageBox.Show("not charcters");
                    }
                }
            }
        }

你可能感兴趣的:(C#,职场,asp.net,休闲,字母转换)