Thursday, November 8, 2018

Reverse characters in a string

C# এ একটা program লিখবো যার কাজ হবে একটি string এর characters গুলোকে reverse order এ সাজিয়ে দেয়া -

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

namespace MainPrograms
{
    public class Program
    {
        public static void Main(string[] args)
        {
            // Prompt the user to enter the string
            Console.WriteLine("Please enter your Desire String");

            // Read the user string from console
            string InputedString = Console.ReadLine();


            // The simple way to reverse a string is to use
            // the built-in .net framework Reverse() function
            List<char> OutputCharacterList = InputedString.Reverse().ToList();

            // Finally print each character from the collection
            foreach (var item in OutputCharacterList)
            {
                Console.WriteLine("{0}", item);
            }

            Console.ReadLine();
        }
    }
}

No comments:

Post a Comment