C# - What does "\0" equate to?

'\0' is a "null character". It's used to terminate strings in C and some portions of C++. Pex is doing a test to see how your code handles the null character, likely looking for the Poison Null Byte security exploit.

Most C# code has nothing to fear; if you pass your string to unmanaged code, however, you may have problems.

Edit:

Just to be explicit... Pex is passing a string containing a null character. This is not a null reference.


It's a string containing the character '\0'. C# doesn't treat this in any particularly special way - it's just unicode character U+0000. If you write:

int firstCodePoint = text[0];

then you'll find firstCodePoint is 0.


It's a string with a null character. Older string libraries — like that used in C or older C++ libraries — used the '\0' character to indicate the end of the string.

Newer environments like .Net use a different system, but there is a lot of history around ending a string with '\0', such that it's a common point of error. Testing libraries like Pex will use it to make sure your program handles it correctly.