DataSet HasTables Method

DataSet Extentions.
Add Methods to Objects.

So, it's getting me tired to always right:
     if (ds != null && ds.Tables.Count > 0)
to make sure that a certain dataset really has tables inside.

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

Simple, yet efficient :)

Elad Shalom,
CTO at ITweetLive.com

Comments

Popular posts from this blog

Cloud Computing Advantages and Disadvantages

Linked Files in Visual Studio 2010

BDD, TDD, and Everything Between