C# key words

C# key words

Key words are predefined reserved words that you can’t use for things like variable names unless they have a @ prefix. (so @int could be a variable name but int can’t.) There are also contextual keywords that are only predefined in certain contexts so you can use them as identifiers if you want. For example orderby is only predefined when its used in a query as a clause.

There are about 77 key words(not including contextual ones) so I will be breaking them into categories.

The first category of key words are types, so these would be words used to say that this variable is a number or its a word.

1.char: is typically a single letter, or number of some kind, which is a Unicode UTF-16 character, and its a reference type

2.decimal: is a floating type numeric value so it can be any number from ±1.0 x 10^28 to ±7.9228 x 10^28, its generally for really precise numbers because it can go to 28-29 digits(after the decimal point I think) and its a value type

3.double: is a floating type numeric value so it can be any number from ±5.0 × 10−324 to ±1.7 × 10308 , its typically the one I use when coding, and it has the ability to go to 15 to 17 digits(after the decimal point I think) and its a value type

4.int:is a integer number so it can’t represent any kind of decimal, its range is -2,147,483,648 to 2,147,483,647 and its a value type

5.sbyte: is also for integer numbers and its range is -128 to 127 and its a value type

6.float:is a floating type numeric value so it can be any number from ±1.5 x 10−45 to ±3.4 x 1038 and it can have 6 to 9 digits(after the decimal point I think) and its a value type

7.object: this can be whatever, its basically the super class of all the reference type

8.bool: is a structure type and can only be true or false, this is generally the output of a if statement, if the statement is true it runs the code blocked by the if statement if false it doesn’t. The default for bool is false.

True and false are keywords and are the output of a bool.

9.short:is also for integer numbers and its range is -32,768 to 32,767 and its a value type

10.string : is a sequence of zero or more Unicode characters and its a reference type.

11.uint: is also for integer numbers and its range is 0 to 4,294,967,295 and its a value type

12.ushort :is also for integer numbers and its range is 0 to 65,535 and its a value type

13.byte: is also for integer numbers and its range is 0 to 255 and its a value type

14.long: is also for integer numbers and its range is -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 and its a value type

15.ulong : is also for integer numbers and its range is 0 to 18,446,744,073,709,551,615 and its a value type

16.struct: is a value type that encapsulates data and is generally related to functionality.

The next category is modifiers:(coming later)

One thought on “C# key words

Comments are closed.