This article is a mirror article of machine translation, please click here to jump to the original article.

View: 18182|Reply: 0

[Communication] The difference between C# Linq First and FirstOrDefault

[Copy link]
Posted on 1/31/2019 3:06:31 PM | | |
Enumerable.First method

Returns the first element in the sequence.

Enumerable.FirstOrDefault method

Returns the first element in the sequence; If no elements are included in the sequence, the default value is returned.



Note: When using it, if it returns an object, it is recommended to use FirstOrDefault and perform a negative operation on the returned object







Previous:=> is a Lambda expression used to create a default delegation
Next:C# subString understanding
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com