Having studied the switch documentation and discovering it can only switch on integral types I set about looking for a definition. I can't find one anywhere. I can only find a list of integral types.
I could take a guess that integral types are the types which are integrated into the language, however I'd be happier with a proper definition. Does anyone have one?
A type is integral if it is a type of integer; it is impossible to define your own integer type, therefore the types of integer are sbyte, byte, short, ushort, int, uint, long, ulong.
The integral types are: char , signed char , unsigned char -8 bits.
Integral types are types that have integer values. These are int, long, short, byte, and char.
Built-in types (also called fundamental types) are specified by the C++ language standard and are built into the compiler. Built-in types aren't defined in any header file. Built-in types are divided into three main categories: integral, floating-point, and void. Integral types represent whole numbers.
"Integral" refers to integer types (i.e. whole numbers). In C# this means types like int
, long
, short
, etc.
Please see Integral Types Table (C# Reference):
The following table shows the sizes and ranges of the integral types, which constitute a subset of simple types.
Edit: Keep in mind that the switch
statement supports literal strings as well.
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