Question about logical operand.

I am looking at some VB.net code and see this line of code ==>   var type = fInfo?.FieldType ?? pInfo.pType;

I know this is a logical comparison statement, but what does the first question mark mean (finfo?.FieldType)

Can a VB.net expert help me figure that out?
LVL 2
brgdotnetcontractorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Éric MoreauSenior .Net ConsultantCommented:
This is called the Elvis operator. If ever fInfo is null, your application won't trigger an error. It will simply fill type with null. Otherwise (if fInfo is not null), type will be filled with FieldType.
0
Éric MoreauSenior .Net ConsultantCommented:
>>I am looking at some VB.net code and see this line of code ==>   var type = fInfo?.FieldType ?? pInfo.pType;

and BTW, this line is in C#, not in VB.Net
0
Fernando SotoRetiredCommented:
Hi brgdotnet;

It is called the null-conditional Operators. Used to test for null before performing a member access (?.) or index (?[]) operation. These operators help you write less code to handle null checks, especially for descending into data structures.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brgdotnetcontractorAuthor Commented:
Both answers were high quality. Thanks.
0
Fernando SotoRetiredCommented:
Not a problem brgdotnet, glad to help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.