Hello everyone, I am going to
share the code sample for Reverse
string and numbers in with and without using reverse function. The example in
detail as given below.
/// REVERSE STRIG WITH
USING C# FUNCTIONS
public class ReverseStrigs
{
static void Main(string[] a)
{
Console.WriteLine("Enter string for Reverse");
string str = Console.ReadLine();
Console.ReadLine();
}
public static string Reverse(string str)
{
return new string(str.Reverse().ToArray());
}
}
/// REVERSE STRIG
WITHOUT USING C# FUNCTIONS.
public class ReverseStrigs
{
static void Main(string[] ax)
{
Console.WriteLine("Enter string for Reverse");
string str = Console.ReadLine();
Console.WriteLine(Reverse(str));
Console.ReadLine();
}
public static string Reverse(string str)
{
int strLength =
str.Length;
char[] array = new char[strLength];
for (int i = 0; i <
strLength; i++)
{
array[i] = str[strLength - 1 - i];
}
return new string(array);
}
}