Pro EP 78 : How to check NULL or Empty conditions in C# ?

Muhammad Waseem
Become .NET Pro !
1 min readOct 6, 2023

While working with strings we often need to check the empty and null conditions before proceeding further.

string.IsNullOrWhiteSpace() method is best candidate to solve such problems.

It indicates whether a specified string is null, empty, or consists only of white-space characters.

It returns true if the value parameter is null or Empty, or if value consists exclusively of white-space characters.

  • IsNullOrEmpty : It checks null or blank string
  • IsNullOrWhiteSpace : It checks null, blank string or arbitrary number of spaces

Whenever you’re ready, there are 4 ways I can help you

  1. Subscribe to my Weekly .NET Newsletter of C#/.NET with b6000+ Software Engineers.
  2. Promote yourself to 6000+ subscribers by Sponsoring my Newsletter
  3. Download my eBook at Gum Road which contains 30+ .NET Tips (With 2800+ Downloads)
  4. To get 100+ free and paid resources for learning C# and .NET visit this GitHub Repository

--

--