用C#编写一个程序,把字符串“helloworld”以相反顺序输出

如题所述

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication50
{
class Program
{
static void Main(string[] args)
{
Program p = new Program();
string str = "hello wrold!";
Console.WriteLine(p.GetNewStr(str));
Console.ReadLine();
}
public string GetNewStr(string str)
{
string newStr="";
for (int i = 0; i < str.Length; i++)
{
newStr += str[str.Length - i - 1];
}
return newStr;
}
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-03-06
很简单
string str = "helloworld";
for (int i=str.Length; i > 0; i--)
{
Response.Write(str.Substring(i-1,1));
}
相似回答