From the course: .NET Essentials: Working with LINQ

Unlock this course with a free trial

Join today to access over 22,500 courses taught by industry experts.

More extension methods

More extension methods

- [Instructor] Now that we understand the basic syntax, let's look at some other examples. I will be looking at IsItEmpty, Getrandom Element, and Shuffle. Now all three of these are implemented as static methods inside the same class, this first one IsItEmpty takes an Icolleciton of T, and does some Boolean Logic here that says, If the collection is null, or the collection doesn't have any items in it, then that's considered to be Empty. So I can call it like this, If Not colors, IsItempty, then I can print out the collection has some items in it. So that collection has items is true. The next one I'm calling is Getrandom Element, check out the current value that was returned as purple, right here shown in purple. If I run this again, oops, I have to unselected that items, so let's try that again. Now it's orange, now it's yellow. And then finally, the Shuffle, check the order of the items, in the original list…

Contents