Try the following done in a console project but will work with any project type.
using System.Text.RegularExpressions;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
string data = "Hello World nice to be here \t\t";
Console.WriteLine($"{data.Replace("\t", "").RemoveExtraSpaces()}...");
Console.ReadLine();
}
}
public static class Extensions
{
public static string RemoveExtraSpaces(this string sender)
{
const RegexOptions options = RegexOptions.None;
var regex = new Regex("[ ]{2,}", options);
return regex.Replace(sender, " ").Trim();
}
}
}