Javatpoint Logo
Javatpoint Logo

C# Null Propagator

C# Null Propagator is an operator. It is used to check null value in an object reference chain. This operator is a combination of two symbols, question mark (?) and comma (,).

In C# code, if we call a method or property by using null object, compiler throws System.NullReferenceException exception. We receive this exception if we don't check for null in our code.

To avoid this exception, we can use null propagator operator.

In the following example, we are checking for null reference, by using if block, before calling a method.

C# Example without using Null Propagator


Rahul Kumar

In the following example, we are using Null Propagator Operator to check null reference.

C# Example with Null Propagator Operator


[email protected]
Name is empty
Email is empty

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA