Geeks With Blogs

News My Blog has been MOVED to https://mfreidge.wordpress.com
Michael Freidgeim's OLD Blog My Blog has been MOVED to https://mfreidge.wordpress.com

Below are couple simple helper functions to get last element in collection:


 public static Object LastElement(Object[] myArr)
        {
            if( IsNullOrEmpty(myArr))
            {
                return null;
            }
            return myArr[myArr.Length-1];
        }


        public static DataRow GetLastRow(DataTable tbl)
        {
            if (tbl == null) { throw new NullReferenceException("tbl is null"); }
            if (tbl.Rows.Count == 0)
            {
                return null;
            }
            return tbl.Rows[tbl.Rows.Count - 1];
        }

Posted on Wednesday, December 3, 2008 10:06 PM .Net Framework | Back to top


Comments on this post: Helper functions to get last element in collection

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Michael Freidgeim | Powered by: GeeksWithBlogs.net