how to remove space in the middle using c#

Kalaivani picture Kalaivani · Mar 30, 2012 · Viewed 33.3k times · Source

how to remove space in the middle using c#? I have the string name="My Test String" and I need the output of the string as "MyTestString" using c#. Please help me.

Answer

Write like below

name = name.Replace(" ","");