<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/'><id>tag:blogger.com,1999:blog-5459393636366885547.post6663975100780832846..comments</id><updated>2008-09-01T10:02:05.142+02:00</updated><title type='text'>Comments on freakcode: Collection.IsNullOrEmpty</title><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.freakcode.com/feeds/6663975100780832846/comments/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5459393636366885547/6663975100780832846/comments/default'/><link rel='alternate' type='text/html' href='http://blog.freakcode.com/2008/08/collectionisnullorempty.html'/><author><name>Markus Olsson</name><uri>http://www.blogger.com/profile/04294756312801923101</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>4</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-5459393636366885547.post-8528920172495315886</id><published>2008-09-01T10:02:05.142+02:00</published><updated>2008-09-01T10:02:05.142+02:00</updated><title type='text'>Yes I know it would make a candidate for and exten...</title><content type='html'>Yes I know it would make a candidate for and extension method and I thought about it when I wrote the post but I don't feel comfortable using extension methods that accept null parameters since I feel that it breaks common practice and relaxes the view on calling stuff on objects that might be null. &lt;BR/&gt;&lt;BR/&gt;It's just not obvious enough that you're actually calling a static method and passing in null as the first parameter.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5459393636366885547/6663975100780832846/comments/default/8528920172495315886'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5459393636366885547/6663975100780832846/comments/default/8528920172495315886'/><link rel='alternate' type='text/html' href='http://blog.freakcode.com/2008/08/collectionisnullorempty.html?showComment=1220256125142#c8528920172495315886' title=''/><author><name>Markus Olsson</name><uri>http://www.blogger.com/profile/04294756312801923101</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='15307466000806953640'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.freakcode.com/2008/08/collectionisnullorempty.html' ref='tag:blogger.com,1999:blog-5459393636366885547.post-6663975100780832846' source='http://www.blogger.com/feeds/5459393636366885547/posts/default/6663975100780832846' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5459393636366885547.post-3456495680449753290</id><published>2008-09-01T09:26:12.829+02:00</published><updated>2008-09-01T09:26:12.829+02:00</updated><title type='text'>You could also turn this into an extension method:...</title><content type='html'>You could also turn this into an extension method:&lt;BR/&gt;&lt;BR/&gt;public static bool IsNullOrEmpty(this ICollection ic)&lt;BR/&gt;       {&lt;BR/&gt;           return (ic == null || ic.Count == 0);&lt;BR/&gt;       }&lt;BR/&gt;&lt;BR/&gt;Then you can write:&lt;BR/&gt;&lt;BR/&gt;var employees = new List&amp;lt;string&amp;gt;() {&amp;quot;Bob&amp;quot;, &amp;quot;Alice&amp;quot;, &amp;quot;Tom&amp;quot; };&lt;BR/&gt;if(employees.IsNullOrEmpty())&lt;BR/&gt;{&lt;BR/&gt;    FireTheirAsses(employees);&lt;BR/&gt;}&lt;BR/&gt;&lt;BR/&gt;Which then reads the same regardless of the collection implementing ICollection.</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5459393636366885547/6663975100780832846/comments/default/3456495680449753290'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5459393636366885547/6663975100780832846/comments/default/3456495680449753290'/><link rel='alternate' type='text/html' href='http://blog.freakcode.com/2008/08/collectionisnullorempty.html?showComment=1220253972829#c3456495680449753290' title=''/><author><name>Anonymous</name><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.freakcode.com/2008/08/collectionisnullorempty.html' ref='tag:blogger.com,1999:blog-5459393636366885547.post-6663975100780832846' source='http://www.blogger.com/feeds/5459393636366885547/posts/default/6663975100780832846' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5459393636366885547.post-4826934422414973524</id><published>2008-08-30T23:41:47.983+02:00</published><updated>2008-08-30T23:41:47.983+02:00</updated><title type='text'>Nice catch, right you are of course, there's reall...</title><content type='html'>Nice catch, right you are of course, there&amp;#39;s really no need to check for negative values in collections and I&amp;#39;ve updated the post.&lt;BR/&gt;&lt;BR/&gt;To answer your question though. If you look at the IL generated from the &amp;gt;= statement you&amp;#39;ll see that it (as one could expect) calls the clt instrucion (compare less than) and if that succeeds it calls the ceq (check equality) instruction. &lt;BR/&gt;&lt;BR/&gt;I head a fun thought though.. You could just check for Count &amp;gt; int.MinValue =)</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5459393636366885547/6663975100780832846/comments/default/4826934422414973524'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5459393636366885547/6663975100780832846/comments/default/4826934422414973524'/><link rel='alternate' type='text/html' href='http://blog.freakcode.com/2008/08/collectionisnullorempty.html?showComment=1220132507983#c4826934422414973524' title=''/><author><name>Markus Olsson</name><uri>http://www.blogger.com/profile/04294756312801923101</uri><email>noreply@blogger.com</email><gd:extendedProperty xmlns:gd='http://schemas.google.com/g/2005' name='OpenSocialUserId' value='15307466000806953640'/></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.freakcode.com/2008/08/collectionisnullorempty.html' ref='tag:blogger.com,1999:blog-5459393636366885547.post-6663975100780832846' source='http://www.blogger.com/feeds/5459393636366885547/posts/default/6663975100780832846' type='text/html'/></entry><entry><id>tag:blogger.com,1999:blog-5459393636366885547.post-6958334749556713188</id><published>2008-08-30T20:51:16.344+02:00</published><updated>2008-08-30T20:51:16.344+02:00</updated><title type='text'>As earlier stated, this small helper method rocks....</title><content type='html'>As earlier stated, this small helper method rocks. But, I was just wondering; shouldn't it read:&lt;BR/&gt;&lt;BR/&gt;return (ic == null || ic.Count == 0);&lt;BR/&gt;&lt;BR/&gt;Count can't be negative, right? I don't know which of the tests that is performed first ("less than" or "equal to"), but if it starts with "less than", you would save a couple of CPU cycles =)&lt;BR/&gt;&lt;BR/&gt;Cheers! :D</content><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/5459393636366885547/6663975100780832846/comments/default/6958334749556713188'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/5459393636366885547/6663975100780832846/comments/default/6958334749556713188'/><link rel='alternate' type='text/html' href='http://blog.freakcode.com/2008/08/collectionisnullorempty.html?showComment=1220122276344#c6958334749556713188' title=''/><author><name>Christoffer</name><uri>http://www.blogger.com/profile/16778821639429848855</uri><email>noreply@blogger.com</email></author><thr:in-reply-to xmlns:thr='http://purl.org/syndication/thread/1.0' href='http://blog.freakcode.com/2008/08/collectionisnullorempty.html' ref='tag:blogger.com,1999:blog-5459393636366885547.post-6663975100780832846' source='http://www.blogger.com/feeds/5459393636366885547/posts/default/6663975100780832846' type='text/html'/></entry></feed>