DataTable HasRows Method

DataTable Extentions.
Add Methods to Objects.

So, it's getting me tired to always right:
     if (dt != null && dt.Rows.Count > 0)
to make sure that a certain table really have rows.

So here is an extension I added to the DataTable object:
        public static bool HasRows(this DataTable dt)
        {
            if (dt != null && dt.Rows.Count > 0) 
                return true;
 
            return false;
        }

Simple, yet efficient :)
Elad Shalom,
CTO at ITweetLive.com

Comments

Post a Comment

Popular posts from this blog

Linked Files in Visual Studio 2010

Protecting Personal Data

Cloud Computing Advantages and Disadvantages