I am have a Windows Form Application project. In which i want to remove white space from string. Anyone can help me.
How can remove space from a string in C#
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
ali tuncerRank #1,498 · 1.1K reputationPosted May 13, 2016, 12:47 AM EDT
you can use Replace method to replace white space with string.empty, here is an example :
string test = "Mohammed Ashraf";
Console.WriteLine(test.Replace(" ", string.Empty));
ali tuncerRank #1,498 · 1.1K reputationPosted May 12, 2016, 10:16 PM EDT
use Trim extension method..
http://www.dotnetperls.com/trim
Mohammed AshrafRank #900 · 2.3K reputationPosted May 12, 2016, 11:14 PM EDT
Mohammed AshrafRank #900 · 2.3K reputationPosted May 13, 2016, 9:00 PM EDT