c:void

<c:void
  value? = statement_expression >
  <!-- Content: sequence-constructor -->
</c:void>

Evaluates ignoring the result.

Category
instruction
Permitted parent elements
Any XCST element whose content model is sequence-constructor
Any literal result element

Attributes

value The expression to evaluate.

In addition to the attributes in the preceding table, there are a number of standard attributes that may appear on any XCST element.

Remarks

The c:void instruction has two uses. The first use is to call methods that don’t return values (void methods in C#), or when you don’t want to output the return value. The expression in the value attribute must be a valid C# statement.

Example: Redirecting

In the following example, the Redirect method is a void method, you can use c:void to call it.

<c:void value='Redirect("/")'/>

The second use is to evaluate a sequence constructor but discarding the output. This can be useful if you run a program only for its side-effects.

Error Conditions

It is a compilation error if the value attribute is present when the content of the element is non-empty.

See Also