Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Help following code
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
00997079
Message ID:
00997086
Views:
13
>I am looking at some code in C# and I don't know what it's doing. Can anyone show me the light?
>
>ParentCategoryID == 0 ? "NULL" : ParentCategoryID.ToString()
>
>I assume what's doing is returning "null" if ParentCategoryID equals 0 otherwise converting the ParentCategoryID to a string.
>
>However, I don't understand how this construct works. specifically what is the ? function or the : function.
>
>Thank you,
>Paul

Paul,

You are correct. ?: is the C equivalent of VFP's IIF(). If the expression before the ? is true, return what is after the ? and before the :, otherwise return what is after the :

? and : do not have meaning on their own, only as a pair as part of the construct.

HTH,
Chad
_________________________________
There are 2 types of people in the world:
    Those who need closure
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform