1st Method
public string Reverse(string str)
{
int len = str.Length;
char[] arr = new char[len];
for (int i = 0; i < len; i++)
{
arr[i] = str[len - 1 - i];
}
return new string(arr);
}
2nd Method
public string Reverse(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
public string Reverse(string str)
{
int len = str.Length;
char[] arr = new char[len];
for (int i = 0; i < len; i++)
{
arr[i] = str[len - 1 - i];
}
return new string(arr);
}
2nd Method
public string Reverse(string s)
{
char[] arr = s.ToCharArray();
Array.Reverse(arr);
return new string(arr);
}
No comments:
Post a Comment