In C# are the terms “Primitive” and “Literal” interchangeable?

前端 未结 8 763
[愿得一人]
[愿得一人] 2021-02-07 20:43

A discussion earlier today led me to question whether or not my understanding of primtives and literals is correct.


My understanding is that a literal type is spec

8条回答
  •  余生分开走
    2021-02-07 21:25

    Is my understanding (if not my explanation) correct for the most part?

    I do not agree in one point: A literal is some kind of compile time constant (as "Hello World", 5 or 'A'). However, there are no "Literal-Types"; the literal always is the actual value.

    Primitive types are IMO "basic" types like string, int, double, float, short, ...

    So primitive have their types of literals connected with them.

提交回复
热议问题