How to calculate string length without spaces in C#

1 Answer

0 votes
using System;
using System.Linq;

public class calculateStringLengthWithoutSpaces_CSharp
{
    public static void Main(string[] args)
    {
        string s = "Madness - (My Name Is) Michael Caine";
 
        Console.WriteLine(s.Length - s.Count(Char.IsWhiteSpace));
    }
}



/*
run:

30
   
*/



answered Apr 8, 2014 by avibootz
edited Jan 11, 2025 by avibootz

Related questions

1 answer 120 views
1 answer 115 views
1 answer 120 views
1 answer 120 views
1 answer 93 views
1 answer 186 views
1 answer 99 views
...