I have strings in a file that I read. Some have space(s) or tabs at the start. Is there an easy way I can remove the space and tab (whitespace stuff)?
For example
var abc = " def";
What I want is to remove the things before the "def".
thanks,
Update: I believe this is the correct answer:
ch开发者_开发知识库ar[] arr = new char[] { '\t', ' ' }; // Trim these characters
text = text.TrimStart(arr);
Use string.TrimStart()
:
var result = abc.TrimStart();
Use the built in String methods.
abc.Trim()
Just use the Trim method
abc.Trim()
精彩评论