摘要:
最近在论坛中不少网友问"如何把windows安装的所有打印机列出来",在下面的程序中我们将把系统中所安装的打印机用列表框列出来,同时为默认打印机设置缺省值。
在下面的程序中我们用到了两个主要的类,把所有的打印机列表出来用到了printersettings 类,获取系统默认打印机用到了printdocument 类,下面我们就动手实践一下吧。
先新建一......
摘要:
面向对象设计vs.实用主义
这种方法的缺点之一是你必须使用一个大的switch语句结束,但是前辈一直教导我们大的switch语句是较差的设计的表现。通常的面向对象(object oriented,oo)的途径是使用多态性(polymorphism)的。为了达到这个目的,我们先建立一个抽象的基类(base class),接着从该类衍生出所有的消息对象。每个类需要执行串行化、......
如何用C#实时获取CPU利用率
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.");
...
下一页 摘要:
使用c#编写不同的“hello world”程序
1. a beginners hello world
public class helloworld
{
public static void main()
{
system.console.writeline("hello world");
}
}
2. slightly improved ve......