Answers for "reverse string in c#"

C#
16

c# reverse string

public static string ReverseString(string s)
    {
        char[] arr = s.ToCharArray();
        Array.Reverse(arr);
        return new string(arr);
    }
Posted by: Guest on April-07-2020
3

c# reverse a string

public static void Main(string[] args)
        {
            string s = "aeiouXYZ";
           Console.Write(Reverse(s) );
        }

        public static string Reverse(string s)
        {
            var result = new string(s.ToCharArray().Reverse().ToArray() );
            return result;
        }
------------------------------------------------------Option 2
foreach (int v in values.Select(x => x).Reverse())
{
      Console.Write(v + " ");
}
Posted by: Guest on June-16-2020
1

reverse string c#

string str = "Hello World!"; // the string which you want to reverse
string reverse = "";
int length = str.Length - 1; 

while(length >= 0)
{
	reverse += str[length];
   	length--;
}

Console.WriteLine(reverse);  // output: "!dlroW olleH"
Posted by: Guest on April-25-2020
0

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;
        }
Posted by: Guest on July-02-2020
0

c# string reverse

static class StringExtensions
{
public static string Reverse(this string metin)
{
return new string(metin.ToCharArray().Reverse().ToArray());
}
}
Posted by: Guest on October-08-2021
0

reverse string in c#

Console.WriteLine("Enter Sequence of on number");
            string seqnumber = Console.ReadLine().ToString();
            string reverseseqnumber = "";
            if (seqnumber.Length == 0) { Console.WriteLine("no input is provided"); }
            if(seqnumber.Length>0)
            {
                for(int i=0;i<seqnumber.Length;i++)
                {
                    reverseseqnumber += seqnumber[(seqnumber.Length-1)-i];
                }
                Console.WriteLine("original value : " + seqnumber + " reverse value :" + reverseseqnumber);             
            }
            else
            {
                Console.WriteLine("Print input in reverse order : " + seqnumber);
            }
            Console.ReadLine();
Posted by: Guest on July-21-2021

C# Answers by Framework

Browse Popular Code Answers by Language