@MustUse

Specifies that you must use a return value.

Instructions

When you call a procedure that returns a value, you can usually ignore the value if it is not necessary for subsequent calculations. For example, a procedure can return an integer error code, but it has almost no risk of errors. If you made the procedure, then you can know the risks.

Other programmers that use your code possibly do not have the time to think about the risks. If a return value is important, then it is necessary to tell the user. You can tell the user when a return value is necessary with the modifier @MustUse.

You can add @MustUse to procedures of the types Method and Sub. If you subsequently call such a procedure and ignore the return value, then the compiler shows a warning.

The warning caused by @MustUse is Level 1. You can increase this warning to an error if you think it is necessary. See the section “Warning” of @Option Directive for more information.

Note: Procedures of the type Function also cause this same warning by default. But you cannot use the modifier @MustUse with functions.

You can also add @MustUse to enumerations and structures. When you do, all procedures that return these data types have the same effect as if you put @MustUse on the procedure.

For a return value to be “used”, it can:

Applies to

Examples

TODO

See also