Day 20 : Data Types in C#
C# Data Types :
As we all know C# is a strongly-typed language. Means we must declare the type of variable which indicates what type of value it going to store such as int, char, float etc. C# is mainly divided data types in two types:
1) Value types includes simple type(like int, float, char and bool), enum types, struct types.
2) Reference types includes class types, interface types, array types.
Numeric data types :
- The numeric data type or numbers are divide into two types based on their size in the memory and capacity to store numbers : integer-type, floating-point type.
- Integer type numbers are the whole numbers without decimal points. Also they can be negative or positive.
- Valid types in integer type are byte, sbyte, short, ushort, int, uint, long, ulong.
- Floating-point type numbers have a one or more decimal points. Also they can be negative or positive.
- Valid types in floating-point type are float, double, scientific number.
Primitive data types :
- The primitive data types means the built-in data types and also we can use them to build other data types.
- The primitive data types are also called as reserved keywords.
- The mostly used primitive data types are int, short, char, float, double, bool.
- The primitive data types are divided into two-types value-type and reference-type which we are going to understand in upcoming blogs.
Data-types and their range :
- Integer (int) : The int data type can store whole numbers from -2147483648 to 2147483647.
- Long (long) : The long data type can store whole numbers from -9223372036854775808 to 9223372036854775807. This long is used when int is not enough to store value.
- Booleans (bool) : The boolean data type can only have two values "true" or "false".
- Characters (char) : The char data type is used to store only one character. The characters must have single quote like 'P' or 'p'.
- Strings (string) : The string data type is used to store sequence of characters. The string values must have double quotes.
Thank You!!!
For more understanding watch below video :
Comments
Post a Comment