将一个字符串倒序
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace paixu
{
class Program
{
public static StringBuilder Get(string str)
{
char[] dd = str.ToCharArray();
IEnumerable<char> aa = dd.Reverse();
StringBuilder sb = new StringBuilder();
foreach (char i in aa)
{
sb.Append(i);
}
return sb;
}
static void Main(string[] args)
{
string str = "abc";
Console.Write(Get(str));
Console.ReadLine();
//或者第二种方法
string str = "fsjfjskfjs";
StringBuilder sb = new StringBuilder();
for (int i = str.Length-1; i >=0; i——)
{
sb.Append(str[i]);
}
Console.WriteLine(sb.ToString());
Console.ReadLine();
}
}
}