In C# 4, wasn't there a short cut for checking for null values like so:
if( myobject?.myproperty?.myotherproperty?.value != null )
The value would return null and not throw an exception.
Anyone have a link to how to use it or at least the syntax?
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
C is a structured, procedural programming language that has been widely used both for operating systems and applications and that has had a wide following in the academic community. Many versions of UNIX-based operating systems are written in C.
This operator is called the safe navigation operator in Groovy.
It is not available in C# yet, not even in C# 4.
If enough people show their support for it, maybe it will get into a hypothetical future version of C#...
Nope, sorry, no such thing. They did consider it, but it didn't make the cut.
In C# there's also ?? operator that is used for testing against null. This is slightly better than ? operator.
(x ?? -1) is equivalent to (x!= null ? x: -1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With