Last post Jan 08, 2018 07:02 PM by aspfun
Jan 08, 2018 06:03 PM|aspfun|LINK
I need code to count the space for the front of string.
For example, the string below has no space:
"this is a test"
The string below has 5 space.
" this is a test"
Jan 08, 2018 06:15 PM|A2H|LINK
code to count the space for the front of string
You can use Linq to get the count of whitespace like below
string inputstr = " this is a test";
int spacecount = inputstr.TakeWhile(Char.IsWhiteSpace).Count();
Make sure you have added the linq namespace to your page
Jan 08, 2018 07:02 PM|aspfun|LINK
It works. Thank you.