My personal preference for more readable code would be to adopt a 'happy path' and return from the method before reaching the loop.
if (listOfStrings is null) return; foreach (string item in listOfStrings) { ... }
A good article on adopting the happy path
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
My personal preference for more readable code would be to adopt a 'happy path' and return from the method before reaching the loop.
A good article on adopting the happy path
Write better code and be a better programmer by NEVER USING ELSE statements
Douglas Parsons ・ Nov 10 '20 ・ 5 min read