Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# reverse string

public static string ReverseString(string s)
    {
        char[] arr = s.ToCharArray();
        Array.Reverse(arr);
        return new string(arr);
    }
Comment

C# reverse a string

using System;
namespace ConsoleApp1
{
    public delegate string ReverseDelegate(string input);
    public class Program
    {
		public static string Reverse(string input)
		{
			char[] charArray = input.ToCharArray();
			Array.Reverse(charArray);
			return new string(charArray);
		}
        public static void Main()
        {
			var inpt = "Hello world";
			string reverse = Reverse(inpt);
			Console.WriteLine(reverse);
        }
}
Comment

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 + " ");
}
Comment

reverse a string in c#

 static string ReverseString(string str)
        {
            if (str.Length > 0)
            {
                return str[str.Length - 1] + ReverseString(str.Substring(0, str.Length - 1));
            }
            else
                return str;
        }
        static void Main(string[] args)
        {
            Console.WriteLine("write something:");
            string something = Console.ReadLine();
            Console.WriteLine(ReverseString(something)); 
        }
Comment

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);
        }
Comment

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"
Comment

c# reverse a string

public string Reverse(string text)
{
    char[] charArray = text.ToCharArray();
    string reverse = String.Empty;
    for (int i = charArray.Length - 1; i > -1; i--)
    {
        reverse += charArray[i];
    }
    return reverse;
}

// or 

public static string Reverse( string s )
{
    char[] charArray = s.ToCharArray();
    Array.Reverse( charArray );
    return new string( charArray );
}
Comment

c# reverse string


public static string Reverse( string s )
{
    char[] charArray = s.ToCharArray();
    Array.Reverse( charArray );
    return new string( charArray );
}

Comment

c# loop backwards


for (int i = myArray.Length; i --> 0; )
{
    //do something
}

Comment

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;
        }
Comment

c# loop backwards

string[] arr = new string[5];
for (int a = arr.Length; --a >= 0;)
{
  // ...
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# object add property 
Csharp :: matrix transpose c# 
Csharp :: c# reflection create generic type 
Csharp :: math in c# 
Csharp :: loop in c# 
Csharp :: How can I get my stripe customer ID? 
Csharp :: link list in c# 
Csharp :: combined 2 arrays 
Csharp :: inheritance 
Csharp :: round image unity 
Csharp :: calculate string length vs pixels c# 
Csharp :: blazor use static json files 
Csharp :: create a hash of an XML c# 
Csharp :: mock async method c# reutrnd 
Csharp :: c# null accessor 
Csharp :: C# wpf show hidden window 
Csharp :: c# winform get access token facebook 
Csharp :: deleting an item from a vector c# 
Csharp :: how to make a beep in c# 
Csharp :: c# how to disable a event 
Csharp :: // Force WPF to render UI changes immediately with this magic line of code... 
Csharp :: wpf ope another project page 
Csharp :: Running C# Example 
Csharp :: c# logical operators 
Csharp :: c# show existing form 
Csharp :: best unity regex for email validation in c# 
Csharp :: unity how to change visual studio version 
Csharp :: quartz .net core execute controller 
Csharp :: duplicate global system runtime versioning targetframeworkattribute 
Csharp :: LINQ return list of unique values with counts 
ADD CONTENT
Topic
Content
Source link
Name
8+4 =