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

string reverse c#

var str = "Your String";
var rev = string.Concat(str.Reverse());
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# string reverse

static class StringExtensions
{
public static string Reverse(this string metin)
{
return new string(metin.ToCharArray().Reverse().ToArray());
}
}
Comment

c# reverse string


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

Comment

c# Write a program to reverse an array or string

// Iterative C# program to reverse an
// array
using System;
 
class GFG {
 
    /* Function to reverse arr[] from
    start to end*/
    static void rvereseArray(int []arr,
                    int start, int end)
    {
        int temp;
         
        while (start < end)
        {
            temp = arr[start];
            arr[start] = arr[end];
            arr[end] = temp;
            start++;
            end--;
        }
    }    
     
    /* Utility that prints out an
    array on a line */
    static void printArray(int []arr,
                            int size)
    {
        for (int i = 0; i < size; i++)
            Console.Write(arr[i] + " ");
         
        Console.WriteLine();
    }
     
    // Driver function
    public static void Main()
    {
        int []arr = {1, 2, 3, 4, 5, 6};
        printArray(arr, 6);
        rvereseArray(arr, 0, 5);
        Console.Write("Reversed array is 
");
        printArray(arr, 6);
    }
}
 
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

PREVIOUS NEXT
Code Example
Csharp :: unity transparent object 
Csharp :: accessing form controls from another class c# 
Csharp :: remove comma from string c# 
Csharp :: javascript close page after 5 seconds 
Csharp :: increase timeout in .net core web app 
Csharp :: onkeypressed unity 
Csharp :: this in unity 
Csharp :: unity cos 
Csharp :: c# if statement one line 
Csharp :: unity get child gameobject 
Csharp :: c# get command line arguments 
Csharp :: c# console save file 
Csharp :: c# read file 
Csharp :: linq query select top 1 c# 
Csharp :: getting the row of max value c# linq 
Csharp :: if in dictionary c# 
Csharp :: WPF Confirmation MessageBox 
Csharp :: c# console header 
Csharp :: No Entity Framework provider found for the ADO.NET provider with invariant name 
Csharp :: what does static mean in c# 
Csharp :: c# loop through list of objects 
Csharp :: how to pass string value to enum in c# 
Csharp :: how to start a webpage from a button c# 
Csharp :: c# clamp 
Csharp :: how to check that string has only alphabet in c# 
Csharp :: c# razor add disabled to button if 
Csharp :: get tree node godot 
Csharp :: c# remove first line from textbox 
Csharp :: valid URL check in c# 
Csharp :: c# delegate 
ADD CONTENT
Topic
Content
Source link
Name
9+1 =