Q:

How can I determine an empty string when its contents is \0\0\0\0

I have a SizeOfData variable of byte[4] which returns:
byte[0] == 0
byte[1] == 0
byte[2] == 0
byte[3] == 0

When I do Encoding.ASCII.GetString(SizeOfData) the string variable's length is 4 and String.IsNullOrEmpty() returns false however when I look at the string in Visual Studio there is nothing in it.
How can I determine that if it contains all \0\0\0\0 then do X else Y?

A:

A little bit of linq magic
if (bytes.All(b => b == 0))

or the slightly better
if (bytes.Any(b => b != 0))

