Linq By Example

Any

Used to determine if any elements match a condition (Or any exist at all if no predicate given).

Any Elements

Any can be used to determine if the list is empty or has any amount of items.
    
using System;
using System.Collections.Generic;
using System.Linq;

var myList = new List();
Console.WriteLine(myList.Any()); //Writes false. 

myList.Add(1);
Console.WriteLine(myList.Any()); //Writes true. 

  

Any Elements Matching Condition

Any can also be used to determine if any elements match a specific condition. Will only return True or False. If you require to know the number of matching elements, then you should use Count instead.
    
using System;
using System.Collections.Generic;
using System.Linq;

var myList = new List();
Console.WriteLine(myList.Any(x => x == 1)); //Writes false. 

myList.Add(1);
Console.WriteLine(myList.Any(x => x == 1)); //Writes true. 

  

Performance Of Any vs Count

Any is generally more performant than Count due to the fact that if Any finds a matching element, it returns immediately whereas Count must traverse the entire list. This makes the usage of Count() > 0 much less performant.

It should also be noted that this is especially pronounced when the matching element may be found at the start of a large list, as per the example below.
    
using System;
using System.Diagnostics;
using System.Linq;

var myList = Enumerable.Range(1, 10000000);

var stopWatchAny = new Stopwatch();
stopWatchAny.Start();
var resultAny = myList.Any(x => x == 1);
stopWatchAny.Stop();
Console.WriteLine($"Any completed in : {stopWatchAny.ElapsedMilliseconds} ms");

var stopWatchCount = new Stopwatch();
stopWatchCount.Start();
var resultCount = myList.Count(x => x == 1) > 0;
stopWatchCount.Stop();
Console.WriteLine($"Count completed in : { stopWatchCount.ElapsedMilliseconds} ms");