Data types in
C
# Various data types are provided in C# to represent different data values. These types are divided into the following main categories:
Value types
-
Integer types: byte, sbyte, short, ushort, int, uint, long, ulong
-
Floating point type: float, double
-
Character type: char
-
Boolean type: bool
-
Enumeration type: enum
Reference type
-
Class: Self declared as class Defined type
-
Structure: Custom type declared as struct
-
Array: Declared as T[]
-
String: string (actually an alias for the char[] array)
-
Delegate: Type declared as delegate X Y
Other types
-
null: A special value representing no value
-
dynamic: A type that allows the type to be determined at runtime
-
Void: Represents a type that does not return a value
Detailed description
Value type:
- Stored on the stack.
- Contains values directly, rather than references to other values or objects.
- When copying, create a copy of the value.
Reference type :
- is stored in the heap.
- Contains a reference to another object or value.
- When copying, create a reference to the original object.
Other types:
-
Null: Represents a missing or uninitialized value.
-
Dynamic: Does not check types at compile time, allowing types to be determined dynamically at runtime.
-
Void: Usually used for the return type of a method or function, indicating that the method or function does not return any value.
The above is the detailed content of What data types are provided in c#. For more information, please follow other related articles on the PHP Chinese website!