❔ Tersest way to get (up to) last 3 elements in an array? (source array may have less than 3 items!)
Hello, trying to do something "simple", splitting a path string by
\
and getting the last 3 folders:
The problem is this doesn't work if the Split()
returns an array less than 3 long. I get an out of range exception)
Is there some very terse work around that will get me the last 3 elements (or up to 3) of an array?2 Replies
I guess something like this would work,, but I hope there is something more terse you can come up with 🙂
cool that will work! 😄 much thanks
I have to learn linq more 4sure
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.