The original code uses conditional operators to assign a value to the statusarticleid
variable based on different conditions. This code can be simplified using the null-coalescing operator ??
, as follows:
main.cs113 chars4 lines
This code checks if eventarticlelink
is not null, and if it is not null, it accesses the oid
property of the eventarticle
. If eventarticlelink
is null, it checks if articlesubarticle
is not null and if it is not null, it accesses the oid
property of the subarticle
. If both eventarticlelink
and articlesubarticle
are null, it assigns the value 0
to statusarticleid
.
gistlibby LogSnag