标题:[求助]为什么会出错呢?
只看楼主
唐伯猫
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:5323
专家分:58
注 册:2005-8-9
结帖率:25%
 问题点数:0 回复次数:8 
[求助]为什么会出错呢?
using System; using System.Diagnostics; using System.Threading; public class CpuLoadInfo { // auxiliary print methods private static void Say ( string txt ) { Console.WriteLine(txt); } // auxiliary print methods private static void Say() { Say(""); } // The main method. Command line arguments are ignored. [STAThread] public static void Main() { Say("$Id: CpuLoadInfo.cs,v 1.2 2002/08/17 17:45:48 rz65 Exp $"); Say(); Say("Attempt to create a PerformanceCounter instance:"); Say("Category name = " + CategoryName); Say("Counter name = " + CounterName); Say("Instance name = " + InstanceName); PerformanceCounter pc = new PerformanceCounter(CategoryName,CounterName,InstanceName); Say("Performance counter was created."); Say("Property CounterType: " + pc.CounterType); Say(); Say("Property CounterHelp: " + pc.CounterHelp); Say(); Say("Entering measurement loop."); while (true) { Thread.Sleep(1000); // wait for 1 second float cpuLoad = pc.Nextvalue(); Say("CPU load = " + cpuLoad + " %."); } } // constants used to select the performance counter. private const string CategoryName = "Processor"; private const string CounterName = "% Processor Time"; private const string InstanceName = "_Total"; }

总是出现"“System.Diagnostics.PerformanceCounter”并不包含对“Nextvalue”的定义",怎么改才对呢?

搜索更多相关主题的帖子: private methods public create 
2005-08-17 11:03
绿风
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-8-16
得分:0 
没什么错误啊!
你在试一试!

2005-08-17 18:08
唐伯猫
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:5323
专家分:58
注 册:2005-8-9
得分:0 
以下是引用绿风在2005-8-17 18:08:16的发言: 没什么错误啊! 你在试一试!
真怀疑是你的机器有毛病,我怎么就是运行不了啊!还是你在试试好了!总会就这样的错误:“并不包含对“Nextvalue的定义 ”

<iframe name="alimamaifrm" frameborder="0" marginheight="0" marginwidth="0" border="0" scrolling="no" width="300" height="170" src="/go/app/tbk_app/chongzhi_300_170.php?pid=mm_28854300_2441872_11377541&page=chongzhi_300_170.php&size_w=300&size_h=170&stru_phone=1&stru_game=1&stru_travel=1" ></iframe>
2005-08-17 18:15
scx2002112
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2005-8-18
得分:0 
不会是Nextvalue大小写错了吧.........

2005-08-18 09:46
smiles
Rank: 1
等 级:新手上路
帖 子:123
专家分:0
注 册:2005-8-8
得分:0 
using System.Diagnostics; 试一下

2005-08-18 11:45
唐伯猫
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:5323
专家分:58
注 册:2005-8-9
得分:0 
以下是引用smiles在2005-8-18 11:45:12的发言: using System.Diagnostics; 试一下
上面不是有吗?怎么还要写呢?

<iframe name="alimamaifrm" frameborder="0" marginheight="0" marginwidth="0" border="0" scrolling="no" width="300" height="170" src="/go/app/tbk_app/chongzhi_300_170.php?pid=mm_28854300_2441872_11377541&page=chongzhi_300_170.php&size_w=300&size_h=170&stru_phone=1&stru_game=1&stru_travel=1" ></iframe>
2005-08-18 15:08
zousoft
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2005-3-22
得分:0 
把float cpuLoad = pc.Nextvalue();这句中的Nextvalue中的v改成大写就行了,也就是NextValue

2005-08-18 17:16
baliang
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2005-8-18
得分:0 
对 是可以了 呵呵
2005-08-18 17:59
唐伯猫
Rank: 8Rank: 8
等 级:贵宾
威 望:45
帖 子:5323
专家分:58
注 册:2005-8-9
得分:0 
多谢7楼了,同时感谢大家的积极参与!

<iframe name="alimamaifrm" frameborder="0" marginheight="0" marginwidth="0" border="0" scrolling="no" width="300" height="170" src="/go/app/tbk_app/chongzhi_300_170.php?pid=mm_28854300_2441872_11377541&page=chongzhi_300_170.php&size_w=300&size_h=170&stru_phone=1&stru_game=1&stru_travel=1" ></iframe>
2005-08-18 19:59



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-25376-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.513989 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved