Comments and blocks


For comments the usual XML comments <!-- --> may be used, or rem action:


There are basic loops, blocks, and conditionals in XSharper. But with C# behind it, you can also use any construction C# allows.

The most primitive structure is sequence, which is just a sequence of commands:


Block is a special sequence, which can be followed by the standard try/catch/finally:


Throwing exceptions

Exceptions may be thrown as


If class is not specified, exception of type ScriptUserException is thrown:

There is a special exception type ScriptTerminateException which terminates the execution of the current script with error code. Unlike other exceptions, it is rethrown at the end of catch in blocks, making it similar to ThreadAbortedException in .NET:


This is useful for premature script termination, and there is shorter notation:

Error message can be produced too