The ?. Operator in foreach Will Not Protect From NullReferenceException

2 years ago 31
BOOK THIS SPACE FOR AD
ARTICLE AD

1. July 2021

This article has been indexed from DZone Security Zone

Do you like the ?. operator? Well, who doesn’t? Many people like these concise null checks. However, today’s article shows that the ?. operator may be tricky sometimes. That is, it can create an illusion of safety when used in the foreach loop.

Let’s start with a small task. Take a look at the following code:

Read the original article: The ?. Operator in foreach Will Not Protect From NullReferenceException

Related

Read Entire Article