best way to check if a datatable is empty

I have a datatable that is part of a class definition.
I will be querying the database the first time this variable is accessed in a private method.

private DataTable _lookup = new DataTable();

What is the best way to do it?

I currently use

_postlablookup.Rows.Count == 0

But it feels like there must be something better. Could I just check for null?

What are the pros and cons of each method?
LVL 1
ol muserTechnology GeneralistAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
käµfm³d 👽Connect With a Mentor Commented:
You should really be checking for both:

if (_lookup != null && _lookup.Rows.Count > 0)
{
    // code
}

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.