How to Get Total Physical RAM in C#
By Tan Lee Published on Jan 08, 2025 502
Retrieving the total installed physical memory (RAM) on the system is straightforward.
You can easily access the system's total physical memory (RAM) programmatically using C# by adding a reference to Microsoft.VisualBasic in your project.
Next, retrieve the total physical RAM of your system in bytes.
ulong ram = (new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory) / (1024 * 1024);
You should convert the value as follows:
- To get Kilobytes, divide by 1024;
- To get Megabytes, divide by 1024 * 1024;
- To get Gigabytes, divide by 1024 * 1024 * 1024, and so on.
Categories
Popular Posts
Material Lite Admin Template
Nov 14, 2024
11 Things You Didn't Know About Cloudflare
Dec 19, 2024
Toolbox Admin Responsive Tailwind CSS Admin Template
Nov 20, 2024
Regal Admin Dashboard Template
Nov 18, 2024