Well first of all, I want to know if it is true, is Linq faster than default Collections methods like, contains(), size() etc...

for example if I load a 3MB text list into a List<T> to find a specific string, will it be faster to use Linq or normal methos like foreach + Equals()?

To test the speed of foreach vs LINQ I created ten million GUID then randomly picked one to search for. The two methods tested where:

foreach (String s in myList) {
    if (s.Equals(toFind)) {
        found = s;
        break;
    }
}

var found = myList.Find(n => n.Equals(toFind));

There was no difference in speed. Decompliling into assembly shows that the LINQ method makes several calls into routines in the .Net framework that the foreach method does not make. I'd assume those are the routines that handle the enumeration through the list for LINQ.

Just FYI ten million GUID is 360 megabytes of data.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.