How to reverse char array in C#

1 Answer

0 votes
using System;

class Program
{
    static void Main() {
        char[] arr = new char[] {'a', 'b', 'c', 'd', 'e', 'f', 'g'};

        Array.Reverse(arr);

        foreach (char ch in arr)
            Console.Write(ch + " ");
    }
}





/*
run:

g f e d c b a 

*/

 



answered Jan 3, 2023 by avibootz

Related questions

1 answer 127 views
1 answer 122 views
122 views asked Jan 3, 2023 by avibootz
1 answer 140 views
1 answer 73 views
1 answer 105 views
105 views asked Dec 30, 2023 by avibootz
1 answer 139 views
1 answer 170 views
170 views asked Aug 15, 2022 by avibootz
...