在电脑上检索的RAM总量 [英] Retrieving Total amount of RAM on a computer
问题描述
可能重复:结果
的 C# - 你怎样的RAM计算机有
下面将检索RAM可用有多少:
The following would retrieve how much ram is available:
PerformanceCounter ramCounter;
ramCounter = new PerformanceCounter("Memory", "Available MBytes");
Console.WriteLine("Total RAM: " + ramCounter.NextValue().ToString() + " MB\n\n");
当然,我们将不得不使用System.Diagnostics程序;类。
Of course we will have to use the System.Diagnostics; class.
是否具有的PerformanceCounter检索特定的机器的RAM数量的功能?我不是在谈论RAM的使用或不使用的量。我说的RAM,该机拥有量。
Does performancecounter have any functionality for retrieving the amount of RAM of a particular machine? I'm not talking about the amount of ram used or unused. I'm talking about the amount of ram the machine has.
推荐答案
这信息已经直接在.NET框架中,你可能也使用它。 。项目+添加引用,选择Microsoft.VisualBasic程序
This information is already available directly in the .NET framework, you might as well use it. Project + Add Reference, select Microsoft.VisualBasic.
using System;
class Program {
static void Main(string[] args) {
Console.WriteLine("You have {0} bytes of RAM",
new Microsoft.VisualBasic.Devices.ComputerInfo().TotalPhysicalMemory);
Console.ReadLine();
}
}
不,它不会把你的C#代码到vb.net。
And no, it doesn't turn your C# code into vb.net.
这篇关于在电脑上检索的RAM总量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!