The first method checks if the string is empty or empty. In your example, you can risk a null reference since you are not checking for null before trimming
1- string.IsNullOrEmpty(text.Trim())
The second method checks if the string is null or an arbitrary number of spaces in the string (including an empty string)
2- string .IsNullOrWhiteSpace(text)
The IsNullOrWhiteSpace method covers IsNullOrEmpty , but also returns true if the string contains a space.
In your specific example, you should use 2), because you run the risk of excluding the reference reference position in approach 1), since you are causing the line to be truncated, which may be null
TGH Sep 10 '13 at 4:21 2013-09-10 04:21
source share