Hey

I want to remove all strange whitespaces (such as Alt+0160) except the actual space, as in spacebar.

How can I do this?

Recommended Answers

All 2 Replies

Determine if a char is whitespace and exclude a space. Look here for a start.
If you are familiar with Regex, you could use that as well.

new String(stringVariable.Where(c => !char.IsWhiteSpace(c) || c.Equals(' ').ToArray());

Substitute stringVariable for the actual variable of your existing string. This will return you a string with all whitespace except for spacebar removed.

In ddanbe's defense, he replied with appropriately the right information given what you had posted. However, seeing your other post and that you're an active forum member, I decided to give a more direct answer.

commented: Ofcourse! LINQ! +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.