Tag Archives: first()

LINQ Single vs SingleOrDefault vs First vs FirstOrDefault

Single(), SingleOrDefault(), First() and FirstOrDefault() are extension methods of the Enumerable class. Many people get confused about the difference between Single, SingleOrDefault, First, and FirstOrDefault methods in Linq. Let’s understand the difference between all these methods as below: Single() SingleOrDefault() First() FirstOrDefault() Description Returns a single, specific element of a sequence Returns a single, specific… Read More »

Filters in jQuery

It allow you to select a specific element based on its position in a group of elements or returns elements that match with the certain criteria. Syntax: $(selector).filter(criteria,function(index)) we will explain some types of filter like first(), last() and eq(), filter() and not() . Exxample:- <!DOCTYPE html> <html> <head> <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js”></script> <script> $(document).ready(function(){ $(“p”).filter(“.elem”).css(“background-color”, “yellow”);… Read More »