using System;
using System.Linq;
static class ReverseString
{
public static void Main()
{
string text = "!uoy htiw eb ecrof eht yaM";
Console.WriteLine(string.Join("", text.Reverse()));
}
}
Tag: c#
Replace multiply whitespaces with single space inside text using C#.
using System;
using System.Text.RegularExpressions;
static class ReplaceWhiteSpaces
{
public static void Main()
{
string text = "This is some text with whitespaces in it . : )";
Console.WriteLine(Regex.Replace(text, @"(\s)\1+", " "));
}
}
Easy way to find all palindromes inside string array using C#.
using System;
using System.Linq;
static class Palindromes
{
private static void Main()
{
string[] words = { "test", "notPalindrome", "azuruza", "aha", "what?", "b" };
Console.WriteLine(string.Join(", ", words.Where(w => w.SequenceEqual(w.Reverse()))));
}
}