TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
long keyword in C# is a built-in value type that serves as an alias for the .NET System.Int64 structure. It represents a 64-bit (8-byte) signed integer, utilizing two’s complement representation to store numerical data.
Technical Specifications
- Underlying Type:
System.Int64 - Memory Size: 64 bits (8 bytes)
- Sign Bit: The most significant bit (MSB) denotes the sign (0 for positive, 1 for negative).
- Minimum Value:
-9,223,372,036,854,775,808(long.MinValue) - Maximum Value:
9,223,372,036,854,775,807(long.MaxValue) - Default Value:
0L
Syntax and Literals
By default, the C# compiler treats numeric literals asint if the value falls within the 32-bit signed integer range. To explicitly instruct the compiler to treat a literal as a long, append the L or l suffix. The uppercase L is standard convention to prevent visual confusion with the digit 1.
Type Conversions
Becauselong is a 64-bit type, it participates in specific implicit and explicit conversion rules within the C# type system.
Implicit Conversions
C# allows implicit conversions tolong from any integral type with a smaller bit-width or an unsigned 32-bit type. A long can also be implicitly converted to floating-point types (float, double) and the decimal type. Conversion to floating-point types may result in a loss of precision, whereas conversion to decimal retains full precision.
Explicit Conversions (Casting)
Conversions from types that exceed the maximum value oflong (like ulong), or from floating-point and decimal types (which truncate the fractional part), require an explicit cast.
Memory Layout
In memory, along is stored as a contiguous 64-bit block. The size of the type can be evaluated at compile-time using the sizeof operator, which yields a constant value and does not require an unsafe context for built-in types.
Master C# with Deep Grasping Methodology!Learn More





