Environment.SystemPageSize Property
Environment.SystemPageSize
This property is available in the Environment Class. It provides information about the working environment like variables, methods used, and system related information in C#.
The SystemPageSize property in the Environment class returns the number of bytes in the memory page of an operating system.
Syntax:
int Environment.SystemPageSize
Return:
It returns an integer of type 32 that represents the number of bytes.
Example 1:
Here, we return the number of bytes of the memory page.
class Linuxhint {
//let's implement SystemPageSize property inside main method
static public void Main() {
//get the bytes of memory page
Console.WriteLine("Number of bytes in Memory page in an Operating System: "+Environment.SystemPageSize );
}
}
Output:
There are 4096 bytes in the memory page of an operating system.
Explanation:
Line 4: We implement our property inside the main() method.
Line 6: Console.WriteLine(“Number of bytes in Memory page in an Operating System: “+Environment.SystemPageSize );
Here, we directly use the SystemPageSize property to return the memory bytes of an operating system.
Example 2:
Here, we return the number of bytes of the memory page by storing the bytes in one variable.
class Linuxhint {
//let's implement SystemPageSize property inside main method
static public void Main() {
//get the bytes of memory page
int total_number=Environment.SystemPageSize;
Console.WriteLine("Number of bytes in Memory page in an Operating System: "+total_number);
}
}
Output:
There are 4096 bytes in the memory page of an operating system.
Explanation:
Line 4: We implement our property inside the main() method.
Line 6: int total_number=Environment.SystemPageSize;
Here, we store the memory bytes inside the total_number integer variable.
Line 7: Console.WriteLine(“Number of bytes in Memory page in an Operating System: “+total_number);
Finally, we display the total_number variable that has memory bytes.
Conclusion
With this article, we came to know that it is possible to return the number of bytes in the memory page of an operating system using the Environment.SystempageSize property. You can implement this in your machine and get to know your memory size of the operating system.
Source: linuxhint.com