static void way1(string testString)
{
Console.WriteLine("Way 1 ------------>");
StringBuilder reverseString = new StringBuilder(testString.Length);
for (int i = testString.Length - 1; i >= 0; i--)
{
reverseString.Append(testString[i]);
}
Console.WriteLine(reverseString.ToString());
}
static void way2(string testString)
{
Console.WriteLine("Way 2 ------------>");
char []temp = testString.ToCharArray();
Array.Reverse(temp);
string reverseString = new string(temp);
Console.WriteLine(reverseString);
}
static void way3(string testString)
{
Console.WriteLine("Way 3 ------------>");
String reverseString = String.Empty;
for (int i = testString.Length - 1; i >= 0; i--)
{
reverseString += testString[i];
}
Console.WriteLine(reverseString);
}
{
Console.WriteLine("Way 1 ------------>");
StringBuilder reverseString = new StringBuilder(testString.Length);
for (int i = testString.Length - 1; i >= 0; i--)
{
reverseString.Append(testString[i]);
}
Console.WriteLine(reverseString.ToString());
}
static void way2(string testString)
{
Console.WriteLine("Way 2 ------------>");
char []temp = testString.ToCharArray();
Array.Reverse(temp);
string reverseString = new string(temp);
Console.WriteLine(reverseString);
}
static void way3(string testString)
{
Console.WriteLine("Way 3 ------------>");
String reverseString = String.Empty;
for (int i = testString.Length - 1; i >= 0; i--)
{
reverseString += testString[i];
}
Console.WriteLine(reverseString);
}
No comments:
Post a Comment