protected override void WndProc(ref Message m) { const int WM_SYSCOMMAND = 0x0112; const int SC_CLOSE = 0xF060; if (m.Msg == WM_SYSCOMMAND && (int) m.WParam == SC_CLOSE) { // User clicked close button this.WindowState = FormWindowState.Minimized; return; } base.WndProc(ref m); }
|
二、如何让Foreach 循环运行的更快
foreach是一个对集合中的元素进行简单的枚举及处理的现成语句,用法如下例所示:
using System;
using System.Collections;
namespace LoopTest
{
class Class1
{
static void Main(string[] args)
{
// create an ArrayList of strings
ArrayList array = new ArrayList();
array.Add("Marty");
array.Add("Bill");
array.Add("George");
// print the value of every item
foreach (string item in array)
{
Console.WriteLine(item);
}
}
}
|
你可以将foreach语句用在每个实现了Ienumerable接口的集合里。如果想了解更多foreach的用法,你可以查看。NET Framework SDK文档中的C# Language Specification.
在编译的时候,C#编辑器会对每一个foreach 区域进行转换。
特别说明:由于各方面情况的不断调整与变化,教育人生网所提供的所有考试信息仅供参考,敬请考生以权威部门公布的正式信息为准。 |