Remove Tabs using String.Replace [C#]

Shaitan00

Junior Contributor
Joined
Aug 11, 2003
Messages
358
Location
Hell
Given a string [line], I want to replace all Tabs in [Line] with spaces.
I know the general code [line = line.Replace(tabs, spaces)] but I seem to be lacking in the syntax department. How would you define (tabs) in the above code?

line = line.Replace( \t , “ “)

Anyway I try it generates errors, how do I illustrate \t as the Tab character to replace?
 
Code:
string strWithTabs = "here is a string     with a tab";

// tab-character
char tab = '\u0009';
String line = strWithTabs.Replace(tab.ToString(), "    ");
 
Back
Top