Skip to content
Discussion options

You must be logged in to vote

There's already a method for this: Enumerable.ElementAtOrDefault.

var b = array1.ElementAtOrDefault(10);

Yes you could argue it's a bit longer than ?, but 1) It already exists, 2) It doesn't normally need to be used very often, and 3) It stands out as being something unusual.

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
1 reply
@Joe4evr
Comment options

Comment options

You must be logged in to vote
4 replies
@DoctorMarvin21
Comment options

@canton7
Comment options

@svick
Comment options

svick Jun 21, 2021
Collaborator

@canton7
Comment options

Answer selected by DoctorMarvin21
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants