Best Methods to Check for Empty Strings in C#

Опубликовано: 26 Июнь 2026
на канале: Paul D. Sheriff
325
6

Lesson: Best Methods to Check for Empty Strings in C#
Technologies: C# and .NET Core

Lesson Description
In this lesson you learn different methods for checking for empty strings or null in C#. You first learn how to check for empty strings using C# operators. Next, you learn to use the IsNullOrEmpty() and IsNullOrWhiteSpace() methods. Finally, the best practice for checking for empty strings or null is presented.

Contents
Introduction 00:00
Prerequisites 00:08
Lesson Objectives 00:14
DEMO: Simulate IsNullOrEmpty() Using Equality and || Operators 00:33
DEMO: Using the IsNullOrEmpty() Method 01:46
DEMO: Simulate IsNullOrWhiteSpace() Using Equality and || Operators 02:52
DEMO: Using the IsNullOrWhiteSpace() Method 04:27
Which Method to Use 05:39

Helpful Links
Samples and hands-on labs for this course: https://www.pdsa.com/YouTube

IsNullOrEmpty() Method
https://learn.microsoft.com/en-us/dot...

IsNullOrWhiteSpace() Method
https://learn.microsoft.com/en-us/dot...

#csharp #string #emptystrings #isnullorempty #isnullorwhitespace #dotnet #dotnetcore #pauldsheriff #pdsa #pluralsight #youtube

Paul.About()
Hello, my name is Paul D. Sheriff and I have a passion for teaching. I have been training developers for over 35 years through books, videos, article, blog posts, and international conferences and user groups.

Paul.Contact()
Website: https://www.pdsa.com
Email: [email protected]
LinkedIn:   / paulsheriff  
Blog: https://blogs.pdsa.com/
Pluralsight: https://app.pluralsight.com/profile/a...
YouTube Channel: @pauldsheriff