C#: Inverser une chaîne de Caractère(String)

Author:


{filelink=19655}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Mesexemples
{
    class Reversion
    {
        static void Main(string[] args)
        {
            String texte = "Bienvenu sur C#";
            Console.WriteLine("Chaîne inversée:{0}",reverseString(texte));
            Console.ReadLine();
        }
        public static String reverseString(String texte)
        {
            string reverseStr = "";
            for (int counter = texte.Length - 1; counter >= 0; counter--)
            {
                reverseStr += texte[counter];
            }
            return reverseStr;
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *