关于#c语言#的问题:A→Z a→zB→Y b→yC→X c→x. .. .. .即第一个字母变成第26个字母,第i个字母变成第(26-i+1)个字母

有一行电文,已按下面规律译成密码:
A→Z a→z
B→Y b→y
C→X c→x
. .
. .
. .
即第一个字母变成第26个字母,第i个字母变成第(26-i+1)个字母,非字母字符不变。要求编程序将密码译回原文,并输出密码和原文。


            //ASCII A=65 Z=90  a=97 z=122
            string ostr = this.textBox1.Text;
            //string ostr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
            string nstr = "";
            int astr = 0;
            string str = "";

            for (int i=0;i< ostr.Length;i++)
            {
                str = ostr.Substring(i, 1);
                astr = (int)System.Text.Encoding.ASCII.GetBytes(str)[0];
                if (astr >= 65 && astr < 91)
                {
                    nstr = nstr + ((char)(26 - (astr - 64) + 1 + 64)).ToString();
                }
                else if (astr >= 97 && astr < 123)
                {
                    nstr = nstr + ((char)(26 - (astr - 96) + 1 + 96)).ToString();
                }
                else
                {
                    nstr = nstr + str;
                }
            }

            this.label1.Text = nstr;