In the above example the literal is 2.
The literal term is not something from . NET or even computation, it is a basic mathematical term.
Literal can be said, roughly speaking, since it is difficult to understand, as a fixed value.
It exists to determine values. The most common is that these values are numbers. Many of these numbers may have a suffix indicated by their type, or they may have prefixes indicating whether the notation is different from decimal (hexadecimal, binary, and octal are common). Another very common literal is what represents a text, a string or even just a character. true
and false
are usually Boolean literals.
Some languages have other literals. Some even allow creating a literal, although rare because it is confusing.
The literal is always constant, but a constant need not be represented by a literal. Many people use the term constant inappropriately for the literal. Although the literal is constant it can be assigned to variables, the literal will never change, but the value of the variable can change.
Literal is exactly as it is placed there, it will not be manipulated, it does not fit interpretation, it is not something representative, it is that and only.
I: "In short, it’s the same thing as a constant?" mustache says: "The literal is always constant", jbueno says: "No. Constants have literal values defined and cannot have value changed during execution."
– CypherPotato
It is written in the answer that.
– Maniero
I edited the comment.
– CypherPotato
A literal is constant. What I meant is that you do not declare a constant because of a literal value.
– Jéf Bueno