Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What exactly are Integral Types?

Tags:

c#

.net

types

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?

like image 546
m.edmondson Avatar asked Mar 01 '11 11:03

m.edmondson


People also ask

What is meant by integral types?

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.

What are the three integral data types?

The integral types are: char , signed char , unsigned char -8 bits.

Which is integral datatype?

Integral types are types that have integer values. These are int, long, short, byte, and char.

What is an integral type C++?

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.


1 Answers

"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.

like image 171
Andrew Hare Avatar answered Sep 20 '22 03:09

Andrew Hare