Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the use of labels in C#?

Tags:

c#

Labels and GOTOs 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#?

like image 475
reshefm Avatar asked Mar 19 '09 15:03

reshefm


People also ask

What are labels used for?

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.

What are labeled statements C?

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.

What is the use of go to and label in C?

A goto statement in C programming provides an unconditional jump from the 'goto' to a labeled statement in the same function.

What are labels in system programming?

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.


1 Answers

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.

like image 51
James Curran Avatar answered Sep 19 '22 01:09

James Curran