c# backwards for loop code example
Example: c# reverse a string for loop
---------------------------------------------------Option 1
foreach (int v in values.Select(x => x).Reverse())
{
Console.Write(v + " ");
}
---------------------------------------------------Option 2
public static void Main(string[] args)
{
Console.Write( Reverse("ABcdefgH") );
}
public static string Reverse(string s)
{
string result = String.Empty;
char[] cArr = s.ToCharArray();
int end = cArr.Length - 1;
for (int i = end; i >= 0; i--)
{
result += cArr[i];
}
return result;
}