Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

reverse a string in c#

static void ReverseString(string str, char[] array, int i)
        {
            array = str.ToCharArray();
            if (i <= 0)
            {
                
                return;
            }
            Console.Write($"{array[i-1]}");

            ReverseString(str, array, --i);
        }
        static void Main(string[] args)
        {
            Console.WriteLine("write something:");
            string something = Console.ReadLine();
            char[] array = new char[something.Length];
            
            ReverseString(something, array, something.Length);
        }
 
PREVIOUS NEXT
Tagged: #reverse #string
ADD COMMENT
Topic
Name
1+4 =