C#学习笔记之-----倒序输出字符串

C#学习笔记之-----倒序输出字符串_第1张图片


学习C#写的第一个程序,很简单啊,以后的代码都放在OSChina上了,VS升级u2后,github上说不定也有了哈。开发工具是VSE 2012。


下面是代码,太简单,没有注释。


#region import
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
#endregion

namespace CSharpStudy
{
    class ReverseString
    {
        public static void Main(String[] args)
        {
            Console.Write("请输入一个字符串:");
            String str = Console.ReadLine();
            if (str == null)
                return;
            String result = "";
            for (int index = str.Length - 1; index >= 0; index--)
            {
                result += str[index];
            }
            Console.WriteLine("倒序的字符串是  {0}", result);
            Console.ReadKey();
        }
    }
}

PS:看到一堆的using不舒服,所以…………。

你可能感兴趣的:(C#学习笔记之-----倒序输出字符串)