Problem statement — Before operating on any collection, we check if the collection is null or empty. Null check is usually done by comparing with Null value.

Solution — To check if the collection is not empty, there are multiple ways. The most common way is to check if collection count > 0. Another way is to check if the collection has at least one element by checking Collection.Any() which returns true when it finds first element.

Analysis —

Consider ‘integers’ is collection of integer numbers, if I need to check if it is empty or not, our first method…

Dipak Gawade

Software geek, blogger. Passionate about learning new concepts and share knowledge.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store