Labels and GOTO
s are considered bad practice and as far as I know there is no reason to use it in C#.
What is the use of labels in C#?
Labels may be used for any combination of identification, information, warning, instructions for use, environmental advice or advertising. They may be stickers, permanent or temporary labels or printed packaging.
Labeled statement syntax The label consists of the identifier and the colon ( : ) character. A label name must be unique within the function in which it appears. In C++, an identifier label can only be used as the target of a goto statement. A goto statement can use a label before its definition.
A goto statement in C programming provides an unconditional jump from the 'goto' to a labeled statement in the same function.
A label is a symbol that represents the memory address of an instruction or data. The address can be PC-relative, register-relative, or absolute. Labels are local to the source file unless you make them global using the EXPORT directive. The address given by a label is calculated during assembly.
Just because they are a disreputable practice, doesn't mean to should close off any possibility of using them. While they may never actually be required, they are occasionally the best way to go.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With