I see many times using native and literals \"keywords\" in C# articles. What do they mean?
examples:
string.Empty article:
From the C# spec section 2.4.4:
A literal is a source code representation of a value.
So for example there are literals for strings and numbers:
string x = "hello";
int y = 10;
... but C# has no literal syntax for dates and times; you'd have to use:
DateTime dt = new DateTime(2011, 12, 11);
As for native support - there are different levels of "native" here, but as far as C# is concerned, I'd usually consider it type-specific support in whatever output format is used. So for example, there are IL instructions to deal with the binary floating point types (float
, double
) but when the C# compiler emits code dealing with decimal
values, it has to call the operators declared in System.Decimal
. I'd therefore consider that float
and double
have native support in IL, but decimal
doesn't.
(It would be possible to write a C# compiler targeting a different platform which did have native support for decimal
- or which didn't have native support for float
and double
, for example. Unlikely, but possible.)
Then when the IL is being run in an execution engine, that will be running on top of "real" native code - x86 for example - which can have specific support for certain types. That's another level of "native". For example, if someone came up with a new version of IL which included native support for decimal
, that wouldn't mean that the CPUs themselves suddenly gained native support.