C Sharp long: Difference between revisions
From Coderwiki
More actions
new: info, size, example |
(No difference)
|
Latest revision as of 08:28, 19 August 2025
The long class in C Sharp is a data type which can store positive and negative whole numbers in variables.
See Integer for generic information about what integers and longs can represent and how they are represented in memory.
Size
edit edit sourceA long in C# is represented by 8 bytes, or 64 bits.
This means it can store integral values from -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807.
For less extreme integers (anything between -2,147,483,648 to 2,147,483,647), you can use the C Sharp int data type instead, which uses less space in memory.
Example
edit edit sourcelong a;
long b = 74;
long c = (long)15.2; // 15