Remove All Whitespace in C#

Published on 03 October 2024 (Updated: 03 October 2024)

Welcome to the Remove All Whitespace in C# page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

using System;
using System.Linq;

class CSharp
{

    public static void ExitWithError()
    {
        Console.WriteLine("Usage: please provide a string");
        Environment.Exit(1);
    }

    public static void RemoveAllWhitespace(string str) {
        Console.WriteLine(
            new string(
                str
                .Where(c => !Char.IsWhiteSpace(c))
                .ToArray()
            )
        );
    }

    static void Main (string[] args)
    {
        if (!args.Any() || args[0] == "") {
            ExitWithError();
        }
        RemoveAllWhitespace(args[0]);
    }

}

Remove All Whitespace in C# was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.