C# string.IsNullOrWhiteSpace("\t") == true

c#

Solution

`\t` is the tab character, which is whitespace. In C# can do either of these to get a tab:

var tab1 = "\t";
var tab2 = "    ";

var areEqual = tab1 == tab2; //returns true

Edit: As noted by Magus, SO is converting my tab character into spaces when the answer gets rendered. If you're in your IDE you'd just hit quote, tab, quote.

As far as a workaround goes, I'd suggest you just add a check for tabs in your conditional.

var delimiter = string.IsNullOrWhiteSpace(foundDelimiter) && foundDelimiter != "\t" ? "," : foundDelimiter;

Problem

I have a line of code ``` var delimiter = string.IsNullOrWhiteSpace(foundDelimiter) ? "," : foundDelimiter; ``` when `foundDelimiter` is `"\t"`, string.IsNullOrWhiteSpace returns true. Why? And what is the approriate way to work around this?

Original source