Sunday, April 15, 2012

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

7 comments:

  1. After approaching several street banks, they almost gave up helpn.us through these loans, the offered
    loan sum ranges from 100 to 1500 pounds with repayment
    use of three months.

    ReplyDelete