DataTypes
1.Integral Types:
byte: 8-bit unsigned integer.
sbyte: 8-bit signed integer.
short: 16-bit signed integer.
ushort: 16-bit unsigned integer.
int: 32-bit signed integer.
uint: 32-bit unsigned integer.
long: 64-bit signed integer.
ulong: 64-bit unsigned integer.
2.Floating-Point Types:
float: 32-bit single-precision floating-point number.
double: 64-bit double-precision floating-point number.
3.Decimal Type:
decimal: 128-bit decimal floating-point number with higher precision for financial and monetary calculations.
4.Character Types:
char: 16-bit Unicode character.
5.Boolean Type:
bool: Represents a Boolean value, which can be either true or false.
6.String Type:
string: Represents a sequence of characters. It's used to store text.
7.Enum Type:
enum: Represents a set of named integer constants. It's a user-defined type.
8.Nullable Value Types:
Adding ? after a value type allows it to be assigned a value or null.
For example, int? nullableInt = null;
Arrays:
You can create arrays of any data type, including custom classes.
Structs:
Similar to classes, but they are value types rather than reference types.
Classes:
Reference types that can contain methods, properties, and fields.
Objects:
The base type of all other types in C#. Every type in C# is implicitly derived from the object type.
Dynamic Type:
dynamic allows you to defer type checking until runtime, enabling more flexible interactions with certain types of data.
Pointers:
C# also supports pointer types, but their use is limited and generally discouraged due to memory safety concerns.
User-Defined Types:
You can create your own classes and structures to define custom data types.
These are the fundamental data types in C#. Depending on your programming needs, you can choose the appropriate data type to represent your data accurately and efficiently. Always consider the size, range, and behavior of different data types when selecting the appropriate one for your application.
Comments
Post a Comment