fbpx
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1

TOPIC: null-coalescing operator in X#?

null-coalescing operator in X#? 2 weeks 3 days ago #1

  Otto's Avatar Topic Author Otto Offline Posts: 139
Two questions:

Is there in X# a null-coalescing operator as in C# the ??
return source ?? String.Empty;
?

Is in X#
iif(source==String.Empty,"is empty","is not empty")
the (only) syntax for the C# ternary conditional operator
source == String.Empty ? "is empty" : "is not empty"
or is there another syntax possible (i'm not looking for the if...then...else...endif construction ofcourse...)

Please Log in or Create an account to join the conversation.

null-coalescing operator in X#? 2 weeks 3 days ago #2

  Chris's Avatar Chris Offline Posts: 1056
Hi Otto,

For (1), you need to use DEFAULT in X#:

return source DEFAULT String.Empty

For (2), yes, iif() is the equivalent of the ... ? ... : ... syntax. Note that iif() is not a function, it is being handled by the compiler, so it is as efficient as the c# version, just a different syntax.
XSharp Development Team
chris(at)xsharp.eu

Please Log in or Create an account to join the conversation.

  • Page:
  • 1