字符串反转

 class Program
    {


        static void Main(string[] args)
        {
            RevertStr();
            Console.Read();
        }
        public static void RevertStr()
        {
            string str = "I_am_a_student";
            string newStr = "";
            string[] str1 = str.Split('_');
            for (int i = str1.Length-1; i >=0;  i--)
            {
                newStr += str1[i] + "_";
            }
            Console.WriteLine(newStr.Substring(0,newStr.LastIndexOf('_')));
        }
    }

  

posted @ 2012-10-23 18:51  威少  阅读(211)  评论(0编辑  收藏  举报