
執行結果就像這樣。
不使用第一排進行排序,而是使用第二或其他排來做排序。
旅遊、水族、調酒
筆者從接觸程式到現在已經有五年了,這段期間碰過很多學習程式設計的人,大部分的人經過五年後還是差不多,但有一些人已經會做很危險的東西。功力的強弱不是看接觸多久,主要是看進步的速度,就像剛剛所說的,大部分的人花了五年的時間,卻達不到少數人一年所成長的功力。就科技產業而言,時間是很重要的,等到你龜速成長完畢後其他人不知道已經賺多少錢了,而且這些已經在賺錢的人不會成長嗎?很多人會問"學程式設計的秘訣是什麼?",其實筆者也不太清楚,如果硬要說的話天分是其中的一環。但光有天分是沒用的,這些成長速度很快的人一定有段時間是花大量時間在程式設計上,而成長速度很慢的人這時候通常在打電動,因為網路遊戲實在太令人著迷了。
Now that you have studied all the pieces, it’s time to put them together and
create a set of real Windows asynchronous network programs. The following two
programs recreate the SimpleTcpSrvr and SimpleTcpClient programs (Listings 5. 1
and 5.2, respectively) introduced in Chapter 5, "Connection-Oriented Sockets,"
but this time they use asynchronous network methods.
The Client Program
The AsyncTcpClient.cs program (Listing 8.2) uses the .NET Windows Forms library
to create a Windows GUI environment for a simple TCP client. In a Windows
environment, it is important that the program respond to Windows events from the
user, as well as from the network
抓取檔案的ICON程式碼 | 複製程式碼(Copy to clipboard) |
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace TestProject
{
public partial class Form1 : Form
{
[System.Runtime.InteropServices.DllImport("shell32")]
private static extern IntPtr ExtractAssociatedIcon(IntPtr hInst, string lpIconPath, ref int lpiIcon);
private IntPtr hIcon;
public Form1()
{
InitializeComponent();
this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
int iIconIndex = 0;
hIcon = ExtractAssociatedIcon(this.Handle, "D:\\123.jpg", ref iIconIndex);
}
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
Icon icon = Icon.FromHandle(hIcon);
e.Graphics.DrawIcon(icon, 10, 10);
}
}
}
Copyright © Kelp-Space 2009