锘??xml version="1.0" encoding="utf-8" standalone="yes"?>99热都是精品久久久久久,久久99国产综合精品女同,日韩精品国产自在久久现线拍http://www.shnenglu.com/Onway/鎴戞槸涓鍙彍鑿滆彍鑿滈笩...zh-cnWed, 07 May 2025 14:04:47 GMTWed, 07 May 2025 14:04:47 GMT60璁よ瘑matplotlibhttp://www.shnenglu.com/Onway/archive/2017/02/11/214675.htmlOnwayOnwaySat, 11 Feb 2017 07:12:00 GMThttp://www.shnenglu.com/Onway/archive/2017/02/11/214675.htmlhttp://www.shnenglu.com/Onway/comments/214675.htmlhttp://www.shnenglu.com/Onway/archive/2017/02/11/214675.html#Feedback0http://www.shnenglu.com/Onway/comments/commentRss/214675.htmlhttp://www.shnenglu.com/Onway/services/trackbacks/214675.html涓錛?/span>matplotlib鏄粈涔?/span>

鍦?/span>python涓敤浜庢暟鎹簱鍙鍖栫殑2D緇樺浘搴撱?/span>


浜岋紝瀹夎

http://matplotlib.org/users/installing.html


涓夛紝浜や簰妯″紡涓庨潪浜や簰妯″紡

1錛岄潪浜や簰妯″紡

鍦?/span>python shell閲岄潰鎵ц

import matplotlib.pyplot as plt
plt.plot([12])
plt.show()

鎵цshow涔嬪悗浼氭墦寮涓涓?/span>GUI紿楀彛鏄劇ず錛屽悓鏃朵氦浜掑懡浠や細闃誨銆?/span>



2錛屼氦浜掓ā寮?/span>

matplotlib.is_interactive()鍙互鏌ョ湅褰撳墠鏄惁鍦ㄤ氦浜掓ā寮忥紱

matplotlib.pyplot.ion()鐢ㄤ簬鎵撳紑浜や簰妯″紡錛?/span>

matplotlib.pyplot.ioff()鐢ㄤ簬鍏抽棴浜や簰妯″紡錛?/span>

import matplotlib.pyplot as plt
plt.ion()
plt.plot([12])

鎵цplot涔嬪悗鎵撳紑浜嗕竴涓?/span>GUI紿楀彛錛屼氦浜掑懡浠ゆ病鏈夐樆濉烇紝緇х畫鎵ц錛?/span>

plt.plot([23])

鍙互鐪嬪埌鍦ㄧ獥鍙i噷闈㈠啀鐢諱簡涓鏉$嚎銆?/span>

涔熷氨鏄湪闈炰氦浜掓ā寮忥紝闇瑕佷竴嬈$敾濂藉啀璋冪敤show鏄劇ず錛涜屼氦浜掓ā寮忓湪姣忔緇樺埗鍚庨兘鑳藉疄鏃剁湅鍒版晥鏋溿?/span>


3錛宨python鐨?/span>magic command 

鍦╥python鐨?matplotlib涔熷彲浠ユ墦寮浜や簰妯″紡銆?/span>

鍦ㄤ氦浜掓ā寮忎腑濡傛灉鏌愪簺淇敼娌℃湁鑷姩鍒鋒柊錛屽彲浠ヨ皟鐢╩atplotlib.pyplot.draw()鍒鋒柊銆?/span>


鍥涳紝鍦╦upyter notebook涓嬌鐢╩atplotlib

1錛?matplotlib

浠ヤ氦浜掓ā寮忔墦寮鐙珛鐨凣UI紿楀彛錛屽鍚屼竴涓猣igure鐨勭粯鍒墮兘鑷姩鍒鋒柊鍒板搴旂殑GUI紿楀彛銆?/span>


2錛岋紖matplotlib notebook

鍚?matplotlib錛屽彧鏄細灝咷UI紿楀彛宓屽叆鍒癱ell鐨勮緭鍑恒?/span>



3錛?matplotlib inline

灝嗙粯鍒剁殑鍥捐漿鎹負闈欐佸浘鐗囧祵鍏ュ埌cell鐨勮緭鍑恒傚湪涓嶅悓鐨刢ell榪涜緇樺埗鏁堟灉涓嶄細鍙犲姞銆?/span>




浜旓紝figure鐨勫悇涓粍鎴愰儴鍒?/span>

http://matplotlib.org/faq/usage_faq.html#parts-of-a-figure


鍏紝matplotlib鐨勪袱縐嶇粯鍥炬帴鍙?/span>

1錛?/span>matlab椋庢牸鎺ュ彛

鎵鏈夌殑plt鍛戒護閮戒細搴旂敤鍒拌嚜鍔ㄥ垱寤虹殑褰撳墠鐨?/span>figure鍜?/span>axes瀵硅薄銆備嬌鐢?/span>plt.gcf鍜?/span>plt.gca鑾峰彇褰撳墠鐨?/span>figure鍜?/span>axes銆?/span>

璋冪敤plt.plot([1, 2])鍗崇粯鍒跺埌鑷姩鍒涘緩鐨?/span>figure鍜?/span>axes銆?/span>

plt.plot([12])
plt.plot([21])


2錛岄潰鍚戝璞℃帴鍙?/span>

鏄懼紡鑾峰緱緇樺埗瀵硅薄錛屽湪鐗瑰畾瀵硅薄鎵ц鐩稿簲鎿嶄綔銆?/span>

fig, ax = plt.subplots()
ax.plot([12])
ax.plot([21])


3錛屽樊鍒?/span>

瀵逛簬綆鍗曠粯鍒朵袱縐嶆帴鍙g殑宸埆涓嶅ぇ錛屽鏉傛儏鍐甸潰鍚戝璞℃帴鍙d細鏇村悎閫傘?/span>

鍙﹀plt鐨勫緢澶氬嚱鏁伴兘鍙互鐩存帴杞負ax鐨勫嚱鏁幫紝渚嬪plt.plot() -> ax.plot()錛屼絾鏌愪簺浼氭湁宸埆錛屼緥濡?/span>plt.xlabel() -> ax.set_xlabel()銆?/span>


涓冿紝鍚勭被鍥懼艦demo

http://matplotlib.org/gallery.html


鍏紝API

http://matplotlib.org/api/index.html



鍙傝冿細

1錛?a >http://matplotlib.org/index.html#

2錛?a >http://matplotlib.org/faq/usage_faq.html#what-is-interactive-mode

3錛?a >http://jupyter.org

4錛?a >http://www.labri.fr/perso/nrougier/teaching/matplotlib/#introduction

5錛?a >http://nbviewer.jupyter.org/github/jakevdp/PythonDataScienceHandbook/blob/master/notebooks/04.00-Introduction-To-Matplotlib.ipynb#Two-Interfaces-for-the-Price-of-One



Onway 2017-02-11 15:12 鍙戣〃璇勮
]]>
goldendict鐨勬湁閬撹瘝鍏告墿灞曠▼搴忥細eyoudao-1.4http://www.shnenglu.com/Onway/archive/2016/02/15/212820.htmlOnwayOnwayMon, 15 Feb 2016 11:57:00 GMThttp://www.shnenglu.com/Onway/archive/2016/02/15/212820.htmlhttp://www.shnenglu.com/Onway/comments/212820.htmlhttp://www.shnenglu.com/Onway/archive/2016/02/15/212820.html#Feedback2http://www.shnenglu.com/Onway/comments/commentRss/212820.htmlhttp://www.shnenglu.com/Onway/services/trackbacks/212820.html涓鏅僋騫磋繃鍘諱簡銆?br />
windows鐨勬湁閬撹瘝鍏擱兘涓嶇煡閬撳崌綰у埌鍝釜鐗堟湰浜嗐?/span>
linux鐨勬湁閬撹瘝鍏稿畼鏂圭増鏈篃鍑烘潵浜嗐?/span>
goldendict宸茬粡1.5鐗堟湰浜嗐?br />
鍗氬涓婂嚑涓湀鍓嶅眳鐒惰繕鏈変竴鏉″叧浜庤繖涓笢瑗跨殑璇勮銆?/span>
灝嗕唬鐮佹壘鍥炴潵璇曚簡涓涓嬪眳鐒惰繕鑳借窇錛屾湁閬撶殑api鍜寈ml鏍煎紡榪樻槸鐪熸槸紼沖畾鍟娿?br />
綆鍗曚慨鏀逛簡涓涓媔nstall鑴氭湰錛岄噸鍐欎簡README錛屾敹鍒癵ithub浜嗭細
https://github.com/Onway/eyoudao
鍘?.3鐗堟湰錛?/span>
http://www.shnenglu.com/Onway/archive/2012/10/22/193668.html


Onway 2016-02-15 19:57 鍙戣〃璇勮
]]>
綆鍗曠殑socks5浠g悊紼嬪簭錛歍hisSockshttp://www.shnenglu.com/Onway/archive/2016/02/12/212809.htmlOnwayOnwayFri, 12 Feb 2016 09:50:00 GMThttp://www.shnenglu.com/Onway/archive/2016/02/12/212809.htmlhttp://www.shnenglu.com/Onway/comments/212809.htmlhttp://www.shnenglu.com/Onway/archive/2016/02/12/212809.html#Feedback0http://www.shnenglu.com/Onway/comments/commentRss/212809.htmlhttp://www.shnenglu.com/Onway/services/trackbacks/212809.html鑳屾櫙
鍓嶆鏃墮棿鍦╠igitalocean縐熶簡vps鎼緩shadowsocks錛岀畝鍗曠湅浜嗕竴涓媠ocks5鍗忚錛屽喅瀹氳嚜宸變篃閫犱竴涓皬杞瓙鐜╃帺銆?/span>
鏄ヨ妭鍦ㄥ鏁寸悊浜嗕竴涓嬩唬鐮侊紝澶х杞繪媿銆?/span>
https://github.com/Onway/ThisSocks

鍔熻兘
浠g爜鏄痗++錛屽湪linux鍩轟簬perfork+select瀹炵幇鐨勶紝鐩墠鐨勫姛鑳芥湁錛?/span>
  • TCP浠g悊
  • 榪滅▼DNS
  • 鐢ㄦ埛楠岃瘉
  • 鏁版嵁鍔犲瘑

榪囩▼
寮鍙戣皟璇曠殑榪囩▼鍙戠幇涓ょ偣姣旇緝鏈夋剰鎬濓細
  1. 鍋跺皵浼氭敹鍒癛ST鐨勬暟鎹寘錛屾煡鐪嬩唬鐮佹棩蹇楋紝鐢╰cpdump鍦ㄤ袱绔姄鍖呭茍鏃犲彂鐜板紓甯?/span>
  2. 璁塊棶鏌愪簺緗戠珯鎬繪槸浼氭敹鍒癛ST鏁版嵁鍖呴犳垚鏃犳硶璁塊棶
瀵逛笂榪扮浜岀偣鍔犲叆浜嗛潪甯哥畝鍗曠殑鏁版嵁鍔犲瘑鍚庡氨瑙e喅浜嗗搱錛宻hadowsocks鐨勫姞瀵嗗簲璇ュ氨鏄繖涔堢敤鐨勫惂銆?br />
緙洪櫡
鍔熻兘涓婃病鏈夋敮鎸乁DP錛宨e鍜宑hrome嫻忚鍣ㄤ技涔庨兘涓嶆敮鎸乻ocks5錛屽彧鑳藉厛鐢ㄧ潃firefox浜嗐?/span>
鍦╳indows涔熺敤c#鍋氫簡涓涓鎴風錛屼絾鏃犳殗欏懼強宸茬粡濂戒箙娌℃洿鏂頒簡銆?br />
鍏朵粬
鍙兘璺熸墍鐢ㄥ甯︽湁鍏籌紝璁塊棶digitalocean鐨勬椂寤惰秴榪?00ms錛岀綉绔欏彧鑳芥墦寮棣栭〉錛岀櫥褰曢〉闈㈤兘鍔犺澆涓嶅叏錛屾厧鐢ㄣ?/span>
鍓嶄簺澶╂敹鍒伴偖浠惰鏄痸ps鍑虹幇嫻侀噺寮傚父琚叧闂簡錛岃繕鏃犳硶鐧誨綍綆$悊欏甸潰錛岀敤lantern涔熶竴鐩磋繛涓嶄笂銆?T_T)


Onway 2016-02-12 17:50 鍙戣〃璇勮
]]>
APUE絎簩绔?UNIX鏍囧噯鍖栧強瀹炵幇http://www.shnenglu.com/Onway/archive/2015/12/08/212438.htmlOnwayOnwayTue, 08 Dec 2015 14:35:00 GMThttp://www.shnenglu.com/Onway/archive/2015/12/08/212438.htmlhttp://www.shnenglu.com/Onway/comments/212438.htmlhttp://www.shnenglu.com/Onway/archive/2015/12/08/212438.html#Feedback0http://www.shnenglu.com/Onway/comments/commentRss/212438.htmlhttp://www.shnenglu.com/Onway/services/trackbacks/212438.html
1, 涓変釜鏍囧噯
1.1, ISO C鏍囧噯鐢盜SO/IEC緇存姢寮鍙?/span>
鏈鏂扮増鏈槸C11錛屽叡鏈?9涓爣鍑嗗ご鏂囦歡銆?/span>

1.2, POSIX鏄竴緋誨垪鐢盜EEE鍒跺畾鐨勬爣鍑?/span>
POSIX鍖呮嫭ISO C鏍囧噯搴撳嚱鏁般?/span>
POSIX鏍囧噯鐨?988鐗堟湰鏄疘EEE 1003.1-1988錛岀粡榪囦慨鏀瑰悗浣滀負IEEE Std.1003.1-1990鎻愪氦ISO錛屾垚涓哄浗闄呮爣鍑咺SO/IEC 9945-1:1990,璇ユ爣鍑嗛氬父縐頒負POSIX.1銆?/span>
褰撳墠鏈鏂扮増鏈槸POSIX.1-2008錛岀敱IEEE鍜孫pen Group鍏卞悓寮鍙戙?/span>

1.3, SUS鏄疨OSIX鐨勮秴闆嗭紝鍏剁郴緇熸帴鍙e叏闆嗙О涓篨SI
The core specifications of the SUS are developed and maintained by the Austin Group, which is a joint working group of IEEE, ISO JTC 1 SC22 and The Open Group.
鍙湁閬靛驚XSI鐨勫疄鐜版墠鑳界О涓篣NIX緋葷粺銆?/span>
褰撳墠鐨勬渶鏂扮増鏈槸SUSv4銆?/span>

1.4, 鎵懼埌涓浜涚綉鍧
C11
http://www.iso.org/iso/home/store/catalogue_tc/catalogue_detail.htm?csnumber=57853

POSIX.1-2008
http://pubs.opengroup.org/onlinepubs/9699919799/
https://standards.ieee.org/findstds/standard/1003.1-2008.html

SUSv4
https://www2.opengroup.org/ogsys/jsp/publications/PublicationDetails.jsp?publicationid=12310
https://en.wikipedia.org/wiki/Single_UNIX_Specification#cite_note-11

2, 闄愬埗
2.1 涓ょ闄愬埗
緙栬瘧鏃墮檺鍒跺拰榪愯鏃墮檺鍒躲?/span>
緙栬瘧鏃墮檺鍒墮氳繃澶存枃浠惰幏鍙栵紱
涓嶄笌鏂囦歡鎴栫洰褰曠浉鍏崇殑榪愯鏃墮檺鍒墮氳繃sysconf鍑芥暟鑾峰彇錛?/span>
涓庢枃浠舵垨鐩綍鐩稿叧鐨勮繍琛屾椂闄愬埗閫氳繃pathconf鍜宖pathconf鍑芥暟鑾峰彇銆?/span>

2.2 ISO C闄愬埗
閮芥槸緙栬瘧鏃墮檺鍒訛紝涓昏瀹氫箟鍦?lt;limits.h>閲岄潰銆?/span>
http://en.cppreference.com/w/c/types/limits

2.3 POSIX闄愬埗鍜孹SI闄愬埗
涔︿腑鍒楀嚭鐨勯兘鏄疄鐜頒腑蹇呴』鏀寔鐨勫悇縐嶆渶灝忓鹼紝鐗瑰畾緋葷粺瀹為檯鏀寔鐨勯檺鍒跺奸渶瑕侀氳繃澶存枃浠舵垨鑰呬笁涓嚱鏁板嚱鏁拌幏鍙栥?/span>
涓変釜鍑芥暟鐨刵ame鍙傛暟鏄檺鍒跺悕鍓嶉潰鍔燺SC_鎴栬卂PC_鍓嶇紑寰楀埌銆?/span>
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html

2.4 涔︿腑浠g爜
/*
 * If  name  is  invalid, -1 is returned, and errno is set to EINVAL.
 * Otherwise, the value returned is the value of the system resource and errno is not changed.
 * In the case of options, a positive value is returned if a queried option is available, and -1 if it is not.
 * In the case of limits, -1 means that there is no definite limit.
*/

#include 
"apue.h"
#include 
<errno.h>
#include 
<limits.h>

#ifdef OPEN_MAX
static long openmax = OPEN_MAX;
#else
static long openmax = 0;
#endif

/*
 * If OPEN_MAX is indeterminate, we're not
 * guaranteed that this is adequate
 
*/
#define OPEN_MAX_GUESS 256

long
open_max(
void)
{
    
if (openmax == 0) { /* first time through */
        errno 
= 0;
        
if ((openmax = sysconf(_SC_OPEN_MAX)) < 0) {
            
if (errno == 0)
                openmax 
= OPEN_MAX_GUESS; /* it's indeterminate */
            
else
                err_sys(
"sysconf error for _SC_OPEN_MAX";)
        }
    }

    
return(openmax);
}

3, 閫夐」
3.1, 閫夐」紜畾鏂瑰紡
緙栬瘧鏃墮夐」瀹氫箟鍦?lt;unistd.h>涓紱
涓庢枃浠舵垨鐩綍鏃犲叧鐨勯夐」鐢╯ysconf紜畾錛?/span>
涓庢枃浠舵垨鐩綍鏈夊叧鐨勯夐」鐢╬athconf鎴栬協pathconf紜畾錛?/span>
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/unistd.h.html

3.2, 閫夐」紜畾嫻佺▼
濡傛灉絎﹀彿甯擱噺鏈畾涔夛紝
瀵筥POSIX鍓嶇紑鐨勯夐」錛屽皢_POSIX鍓嶇紑鏇挎崲涓篲SC鎴朹PC鍓嶇紑錛?/span>
瀵筥XOPEN鍓嶇紑鐨勯夐」錛屽湪_XOPEN鍓嶉潰鍔犱笂_SC鎴朹PC鍓嶇紑錛?/span>
鐒跺悗璋冪敤sysconf, pathconf鎴杅pathconf鍑芥暟銆?/span>
濡傛灉絎﹀彿甯擱噺宸茬粡瀹氫箟錛屽垯鏈変笁縐嶅彲鑳斤細
鍊間負-1錛屼笉鏀寔鐩稿簲鐨勯夐」錛?/span>
鍊煎ぇ浜?錛屾敮鎸佺浉搴旂殑閫夐」錛?/span>
鍊間負0錛岄渶璋冪敤鍑芥暟紜畾閫夐」鏄惁鏀寔銆?/span>
娉細鏌愪簺緋葷粺鍙兘鍑虹幇瀹氫箟浜嗙鍙峰父閲忥紝浣嗘病鏈夊畾涔夊肩殑鎯呭喌銆?/span>

3.4, 浠g爜紺轟緥
鍏堝崰鍧戙?/span>

4, 鍔熻兘嫻嬭瘯瀹?/span>
Feature test macros allow the programmer to control the definitions that are exposed by system header files when a program is compiled.
NOTE:  In  order  to be effective, a feature test macro must be defined before including any header files.  This can be done either in the compilation command (cc -DMACRO=value) or by defining the macro within the source code before including any headers.
see man page feature_test_macros(7).


Onway 2015-12-08 22:35 鍙戣〃璇勮
]]>
shadowsockshttp://www.shnenglu.com/Onway/archive/2015/12/06/212428.htmlOnwayOnwaySun, 06 Dec 2015 09:18:00 GMThttp://www.shnenglu.com/Onway/archive/2015/12/06/212428.htmlhttp://www.shnenglu.com/Onway/comments/212428.htmlhttp://www.shnenglu.com/Onway/archive/2015/12/06/212428.html#Feedback0http://www.shnenglu.com/Onway/comments/commentRss/212428.htmlhttp://www.shnenglu.com/Onway/services/trackbacks/212428.html1, shadowsocks home page
https://shadowsocks.org/en/index.html

2, install shadowsocks server
$ sudo apt-get install python-pip
$ sudo pip install shadowsocks
https://shadowsocks.org/en/download/servers.html

3, shadowsocks server config file
$ vi /etc/shadowsocks.json
{
    "server":"my_server_ip",
    "server_port":8388,
    "local_port":1080,
    "password":"barfoo!",
    "timeout":600,
    "method":"table"
}
https://shadowsocks.org/en/config/quick-guide.html

4, shadowsocks server command
$ ssserver -h // help message
$ ssserver -c /etc/shadowsocks.json -d start // start in daemon mode
$ ssserver -d stop // stop the server

5, shadowsocks-qt5 client for ubuntu 14.04
$ sudo add-apt-repository ppa:hzwhuang/ss-qt5
$ sudo apt-get update
$ sudo apt-get install shadowsocks-qt5
https://github.com/shadowsocks/shadowsocks-qt5/wiki/Installation

6, install genpac to generate PAC file from gfwlist
$ sudo pip install genpac // install
$ genpac --init // generate config.ini and user-rules.txt
-- modify config.ini
$ vi config.ini
[config]
proxy = SOCKS5 127.0.0.1:1080
gfwlist-url = https://raw.githubusercontent.com/gfwlist/gfwlist/master/gfwlist.txt
user-rule-from = /path/to/user-rules.txt
output = /path/to/proxy.pac
$ genpac -c config.ini // generate pac file
https://github.com/JinnLynn/genpac
https://github.com/gfwlist/gfwlist

7, using a PAC file in Firefox
about:preferences#advanced -> Network -> Settings
check 'Automatic proxy configuration URL:'
file:///path/to/proxy.pac
enable 'Remote DNS'
https://www.youtube.com/watch?v=nKB4FoPw15k

Onway 2015-12-06 17:18 鍙戣〃璇勮
]]>
鍙灇涓懼璞′笌鏋氫婦鍣?/title><link>http://www.shnenglu.com/Onway/archive/2015/08/01/211446.html</link><dc:creator>Onway</dc:creator><author>Onway</author><pubDate>Sat, 01 Aug 2015 06:00:00 GMT</pubDate><guid>http://www.shnenglu.com/Onway/archive/2015/08/01/211446.html</guid><wfw:comment>http://www.shnenglu.com/Onway/comments/211446.html</wfw:comment><comments>http://www.shnenglu.com/Onway/archive/2015/08/01/211446.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.shnenglu.com/Onway/comments/commentRss/211446.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Onway/services/trackbacks/211446.html</trackback:ping><description><![CDATA[     鎽樿: 1錛屾渶鍏堝浼氱殑鏄紝緇ф壙浜咺Enumerable鎺ュ彛鐨勭被閮藉彲浠ヤ嬌鐢╢oreach閬嶅巻錛屼絾涓鐩存病鏈夊鎯熾?錛孖Enumerable鍜孖Enumerable<out T>鐨勫畾涔夛細Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->  &nb...  <a href='http://www.shnenglu.com/Onway/archive/2015/08/01/211446.html'>闃呰鍏ㄦ枃</a><img src ="http://www.shnenglu.com/Onway/aggbug/211446.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Onway/" target="_blank">Onway</a> 2015-08-01 14:00 <a href="http://www.shnenglu.com/Onway/archive/2015/08/01/211446.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Dispose妯″紡http://www.shnenglu.com/Onway/archive/2015/07/29/211424.htmlOnwayOnwayWed, 29 Jul 2015 14:50:00 GMThttp://www.shnenglu.com/Onway/archive/2015/07/29/211424.htmlhttp://www.shnenglu.com/Onway/comments/211424.htmlhttp://www.shnenglu.com/Onway/archive/2015/07/29/211424.html#Feedback0http://www.shnenglu.com/Onway/comments/commentRss/211424.htmlhttp://www.shnenglu.com/Onway/services/trackbacks/211424.html1錛屼袱涓摼鎺ラ噷闈㈠凡緇忚В鏋愬畬Dispose妯″紡浜嗭紝鍏朵粬鐨勫彧鏄嚜宸辯殑涓浜涚悊瑙c?/span>
2錛屽鏋滆嚜瀹氫箟綾誨瀷灝佽浜嗛潪鎵樼璧勬簮錛屾垨鑰呭紩鐢ㄤ簡涓涓皝瑁呬簡闈炴墭綆¤祫婧愮殑瀵硅薄鏃訛紙姣斿寮曠敤浜哠qlConnection瀵硅薄錛夛紝搴旇瀹炵幇Dispose妯″紡銆?/span>

3錛屽鏋滆嚜瀹氫箟綾誨瀷緇ф壙鐨勫熀綾婚渶瑕丏ispose錛屼絾璇ュ璞℃湰韜茍娌℃湁闇瑕丏ispose鐨勮祫婧愭椂錛堟瘮濡傚彧鏄檮鍔犱簡涓浜涚畝鍗曠被鍨嬶級錛屾棤闇鑰冭檻Dispose妯″紡銆?/span>

4錛屽鏋滃熀綾誨疄鐜頒簡Dispose錛屽垯鍏舵淳鐢熺被鍙渶閲嶅啓protected綰у埆鐨凞ispose鏂規(guī)硶錛岄噴鏀炬湰綾誨瀷鐨勪嬌鐢ㄥ埌鐨勮祫婧愩?/span>
public綰у埆鐨凞ispose鍜孎inalize鏂規(guī)硶閮芥潵鑷戶鎵褲?/span>
閲嶅啓鐨凞ispose鏂規(guī)硶錛岃寰楁渶鍚庤皟鐢ㄥ熀綾誨甫鍙傜殑Dispose銆?/span>

5錛岄檮鍔犵殑Close鏂規(guī)硶閮芥槸鐩存帴璋冪敤public鏃犲弬鐨凞ispose鏂規(guī)硶銆?/span>

6錛岀被鍨嬬殑鏋愭瀯鍑芥暟浼氳緙栬瘧鍣ㄦ敼涓篎inalize鏂規(guī)硶錛屼笉瑕侀噸杞借繖涓柟娉曘?/span>
鍩虹被鐨凢inalize鏂規(guī)硶鎬繪槸浼氳鑷姩璋冪敤鐨勩?/span>
Finalize鏂規(guī)硶閮戒笉搴旇寮曠敤浠諱綍瀵硅薄銆?/span>

7錛屼笉鎳傝繖孌佃瘽錛屾棦鐒跺熀綾繪病鏈夐渶瑕侀噴鏀劇殑璧勬簮錛屼負浣曡瀹炵幇Dispose妯″紡錛岃屼負浜嗘ц兘鑰冭檻錛屽張涓嶅啓鏋愭瀯鍑芥暟錛?/span>
閭f垜鐨勬淳鐢熺被錛岃繕瑕佸厛鐪嬩竴涓嬪熀綾伙紝鍐嶅喅瀹氳涓嶈鍐欐瀽鏋勫嚱鏁幫紵
Implement the dispose design pattern on a base type that commonly has derived types that hold onto resources, even if the base type does not. If the base type has a Close method, often this indicates the need to implement Dispose. In such cases, do not implement a Finalize method on the base type. Finalize should be implemented in any derived types that introduce resources that require cleanup.

8錛屽璞″湪璋冪敤Dispose涔嬪悗錛岄櫎浜咲ispose浠ュ錛岄兘搴旇鎶涘嚭ObjectDisposedException寮傚父銆?/span>

9錛屽疄鐜頒簡Finalize鐨勫璞★紝鍦ㄧ涓嬈″瀮鍦懼洖鏀剁殑鏃跺欙紝涓嶄細閲婃斁瀵硅薄錛岃屽彧鏄皟鐢ㄥ叾Finalize鏂規(guī)硶錛岀浜屾鍥炴敹鎵嶄細鐪熸閲婃斁瀵硅薄銆?/span>


Onway 2015-07-29 22:50 鍙戣〃璇勮
]]>
鍙樹綋娉涘瀷http://www.shnenglu.com/Onway/archive/2015/07/29/211412.htmlOnwayOnwayWed, 29 Jul 2015 12:23:00 GMThttp://www.shnenglu.com/Onway/archive/2015/07/29/211412.htmlhttp://www.shnenglu.com/Onway/comments/211412.htmlhttp://www.shnenglu.com/Onway/archive/2015/07/29/211412.html#Feedback0http://www.shnenglu.com/Onway/comments/commentRss/211412.htmlhttp://www.shnenglu.com/Onway/services/trackbacks/211412.html鍥犱負鏌愪簺鍘熷洜錛屼竴鐩寸敤鐨勯兘鏄?NET2錛屼絾娓d篃鎬誨緱鏈変簺榪芥眰鏄笉錛岃涓嶅畾鍝ぉ灝辯敤涓婁簡鍛紵

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplicationTest
{
    /*
     * 鍙樹綋娉涘瀷
     *
     * .NET4錛屽湪娉涘瀷鎺ュ彛綾誨瀷鎴栬呮硾鍨嬪鎵樼被鍨嬮噷闈紝
     * 琚叧閿瓧in澹版槑鐨勬硾鍨嬪弬鏁幫紝鍏剁被鍨嬪彲浠ヤ粠鐖剁被鍚戝瓙綾婚嗗彉錛屽彧鑳界敤浣滆緭鍏ュ弬鏁?br />      * 琚叧閿瓧out澹版槑鐨勬硾鍨嬪弬鏁幫紝鍏剁被鍨嬪彲浠ヤ粠瀛愮被鍚戠埗綾誨崗鍙橈紝鍙兘鐢ㄤ簬榪斿洖鍊?br />      * 鏁翠釜娉涘瀷綾誨瀷鏄笉闄愪簬鐢ㄤ綔杈撳叆鍙傛暟榪樻槸浣滀負榪斿洖鍊?br />      *
     * interface IType_IN_OUT<in T1, out T2>
     * IType_IN_OUT<Farmer, Person> farmerPersonType = null;
     * IType_IN_OUT<Person, Farmer> personfarmerType = null;
     * farmerPersonFinder = personFarmerFinder;
     *
     * 涓轟粈涔堜笉鏀寔“鍙樹綋”class鍛紵璺熷瓧孌墊湁鍏崇郴涔堬紵
     
*/

    class Program
    {
        static void Main(string[] args)
        {
            IType_IN<Person> person_in = null;
            IType_IN<Farmer> farmer_in = null;
            farmer_in = person_in;
            Greeting(person_in);
            Console.WriteLine(GetTypeIn() == null);

            IType_OUT<Person> person_out = null;
            IType_OUT<Farmer> farmer_out = null;
            person_out = farmer_out;
            Greeting(farmer_out);
            Console.WriteLine(GetTypeOut() == null);

            Finder_IN<Person> personFinderIn = p => Console.WriteLine(p.GetType());
            Finder_IN<Farmer> farmerFinderIn = f => Console.WriteLine(f.GetType());
            farmerFinderIn = personFinderIn;
            Greeting(personFinderIn);
            Console.WriteLine(GetFarmerFinder().GetType());

            Finder_OUT<Person> personFinderOut = () => new Person();
            Finder_OUT<Farmer> farmerFinderOut = () => new Farmer();
            personFinderOut = farmerFinderOut;
            Greeting(personFinderOut);
            Console.WriteLine(GetPersonFinder().GetType());

            Finder_IN_OUT<Farmer, Person> farmerPersonFinder = f => new Person();
            Finder_IN_OUT<Person, Farmer> personFarmerFinder = p => new Farmer();
            farmerPersonFinder = personFarmerFinder;

            // interface IType_IN_OUT<in T1, out T2>
            IType_IN_OUT<Farmer, Person> farmerPersonType = null;
            IType_IN_OUT<Person, Farmer> personfarmerType = null;
            farmerPersonType = personfarmerType;

            Console.ReadKey();
        }

        static void Greeting(IType_OUT<Person> person)
        {
            Console.WriteLine(person == null);
        }

        static void Greeting(IType_IN<Farmer> farmer)
        {
            Console.WriteLine(farmer == null);
        }

        static IType_OUT<Person> GetTypeOut()
        {
            IType_OUT<Farmer> farmer = null;
            return farmer;
        }

        static IType_IN<Farmer> GetTypeIn()
        {
            IType_IN<Person> person_IN = null;
            return person_IN;
        }

        static void Greeting(Finder_OUT<Person> personFinder)
        {
            Console.WriteLine(personFinder().GetType());
        }

        static void Greeting(Finder_IN<Farmer> farmerFinder)
        {
            Console.WriteLine(farmerFinder.GetType());
        }

        static Finder_OUT<Person> GetPersonFinder()
        {
            Finder_OUT<Farmer> farmerFinder = () => new Farmer();
            return farmerFinder;
        }

        static Finder_IN<Farmer> GetFarmerFinder()
        {
            Finder_IN<Person> person = p => Console.WriteLine(p.GetType());
            return person;
        }
    }

    interface IType_OUT<out T>
    {
    }

    interface IType_IN<in T>
    {
    }

    interface IType_IN_OUT<in T1, out T2>
    {
    }

    delegate T Finder_OUT<out T>();

    delegate void Finder_IN<in T>(T t);

    delegate T2 Finder_IN_OUT<in T1, out T2>(T1 t1);

    class Person
    {
    }

    class Farmer : Person
    {
    }
}


Onway 2015-07-29 20:23 鍙戣〃璇勮
]]>
鏍呮牸鍖栭亾璺覆鏌?/title><link>http://www.shnenglu.com/Onway/archive/2015/07/19/211304.html</link><dc:creator>Onway</dc:creator><author>Onway</author><pubDate>Sun, 19 Jul 2015 05:31:00 GMT</pubDate><guid>http://www.shnenglu.com/Onway/archive/2015/07/19/211304.html</guid><wfw:comment>http://www.shnenglu.com/Onway/comments/211304.html</wfw:comment><comments>http://www.shnenglu.com/Onway/archive/2015/07/19/211304.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/Onway/comments/commentRss/211304.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/Onway/services/trackbacks/211304.html</trackback:ping><description><![CDATA[<span style="font-family: 寰蔣闆呴粦; widows: auto; font-size: 14pt; background-color: #ffffff;">闇姹傦細</span> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">鍦板浘涓奊rid瀵硅薄琛ㄧず涓涓?0*40鐨勬爡鏍鹼紝闄や簡緇忕含搴︿互澶栵紝榪樻湁涓涓寚鏍囧煎淇″彿寮哄害錛屼互鍙婁竴涓牴鎹寚鏍囧肩‘瀹氱殑娓叉煋棰滆壊銆?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">Road瀵硅薄鏄竴鏉$煝閲忛亾璺紝鐢卞涓粡綰害鐐圭粍鎴愩?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">濡傛灉閬撹礬絀胯繃鏌愪釜鏍呮牸錛屽垯灝嗙┛榪囨爡鏍肩殑閭d竴灝忔閬撹礬鎸夋爡鏍肩殑棰滆壊鍊肩敾鍑烘潵錛屾病鏈夌┛榪囨爡鏍肩殑鍏朵粬閬撹礬閮ㄥ垎錛岀敤榛戣壊娓叉煋銆?/span></div> <br /> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">絎竴嬈″仛娉曪細</span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">瀵歸亾璺繘琛岄澶勭悊錛屽皢閬撹礬涓婄殑鍚勪釜鐐瑰綊綾誨埌鍏舵墍灞炵殑鏍呮牸鍐呫?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">鐒跺悗灝嗘爡鏍煎唴鐨勭偣鐢ㄧ嚎榪炶搗鏉ャ?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">瀹屾垚鍚庝竴鐪嬪湴鍥撅紝鎺夊潙閲岄潰浜嗐?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">1錛屼竴鏉¢亾璺┛榪囨煇涓爡鏍鹼紝鏍呮牸鍐呭彲鑳藉彧鏈変竴涓偣錛岃繛涓嶆垚綰匡紱</span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">2錛屼竴鏉$洿綰塊亾璺紝鍙褰曚簡寮澶村拰緇撳熬錛屼腑闂寸┛榪囩殑鏍呮牸灝辨病鐐逛簡</span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">鍚庢潵鎯沖埌鐢ㄨˉ鐐圭殑鏂瑰紡錛屼袱涓偣瓚呰繃20綾沖氨琛ヤ竴涓?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">綆鍗曡瘯浜嗕竴涓嬶紝鏁堟灉涓嶅ソ灝卞紑濮嬬敤絎簩縐嶆柟娉?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"></div> <br /> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">絎簩嬈″仛娉曪細</span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">鍏堝皢閬撹礬鍦ㄧ┖鐧絙itmap涓婄敾鍑烘潵錛岄鑹茬敤榛戣壊錛?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">鍐嶅皢鏍呮牸鍦ㄥ彟涓絀虹櫧鐨刡itmap涓婄敾鍑烘潵錛岄鑹茬敤鍘熸湰鐨勬爡鏍奸鑹詫紱</span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">瀵規(guī)瘮涓ゅ紶bitmap錛屽儚绱犲悓鏃朵笉涓?鐨勫氨鏄浉浜ゅ儚绱狅紝鐢ㄦ爡鏍肩殑鍍忕礌棰滆壊澶嶅埗鍒伴亾璺殑鍍忕礌閲岄潰錛?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">鏁堟灉鏉犳潬鐨勩?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"></div> <br /> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">鍏朵粬鏂規(guī)硶錛?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">鍦ㄨ璁虹粍閲岄潰璇翠簡浠ュ悗錛屽彂鐜板彟涓縐嶆槸棰勫鐞嗗仛娉?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 14pt;">鍒ゆ柇涓ょ偣涔嬮棿璺熸爡鏍肩殑鐩鎬氦錛屽皢鐩鎬氦鐐硅褰曞埌鎵鍦ㄦ爡鏍奸噷闈紝榪欐瘮杈冮傚悎鍚庡彴銆?/span></div> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"></div> <br /> <div style="font-family: 寰蔣闆呴粦; widows: auto; background-color: #ffffff;"><span style="font-size: 18pt;">浠ュ悗榪樻槸榛橀粯鍐欏崥瀹㈠惂錛?/span></div><img src ="http://www.shnenglu.com/Onway/aggbug/211304.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/Onway/" target="_blank">Onway</a> 2015-07-19 13:31 <a href="http://www.shnenglu.com/Onway/archive/2015/07/19/211304.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>Visual Studio鎵╁睍寮鍙戯細AutoProjectFileshttp://www.shnenglu.com/Onway/archive/2015/07/11/211228.htmlOnwayOnwaySat, 11 Jul 2015 11:39:00 GMThttp://www.shnenglu.com/Onway/archive/2015/07/11/211228.htmlhttp://www.shnenglu.com/Onway/comments/211228.htmlhttp://www.shnenglu.com/Onway/archive/2015/07/11/211228.html#Feedback0http://www.shnenglu.com/Onway/comments/commentRss/211228.htmlhttp://www.shnenglu.com/Onway/services/trackbacks/211228.html
璇存槑
鐢ㄤ簬澶氫漢寮鍙戠殑欏圭洰涓斿湪涓嶆彁浜ら」鐩枃浠剁殑鎯呭喌涓嬶紝鑷姩灝嗘柊澧炵殑婧愮爜鏂囦歡鍔犲叆鍒伴」鐩腑鎴栬呭皢鍒犻櫎鐨勬枃浠朵粠欏圭洰涓Щ闄ゃ?br />https://github.com/Onway/AutoProjectFiles

浣跨敤
瀹夎鍚庡湪璧勬簮綆$悊鍣ㄤ腑鍙抽敭欏圭洰鍚嶇О鑺傜偣錛屼細鐪嬪埌“鑷姩鏇存柊欏圭洰”鍜?#8220;鍒涘緩蹇収...”涓や釜閫夐」銆? 
“鍒涘緩蹇収”鏄欏圭洰涓寚瀹氱殑婧愮爜鐩綍寤虹珛涓浠藉凡鏈夋枃浠跺垪琛紝浠ヤ究鍚庣畫鐭ラ亾鏂板鎴栬呭垹闄ょ殑鏂囦歡銆? 
“鑷姩鏇存柊欏圭洰”涔嬪悗錛屽皢浼氬鏂板鎴栧垹闄ゆ枃浠舵洿鏂拌嚦欏圭洰錛屽悓鏃跺埛鏂版枃浠跺揩鐓у垪琛ㄣ?br />
鏁堟灉鍥?br />



Onway 2015-07-11 19:39 鍙戣〃璇勮
]]>
久久夜色精品国产噜噜噜亚洲AV| 日韩精品久久久肉伦网站| 久久精品日日躁夜夜躁欧美| 欧美大香线蕉线伊人久久| 久久久噜噜噜久久中文字幕色伊伊 | 久久精品成人欧美大片| 亚洲AV日韩精品久久久久久| 久久免费视频观看| 国产69精品久久久久APP下载| 九九久久99综合一区二区| 亚洲婷婷国产精品电影人久久| 欧美黑人又粗又大久久久 | 狠狠色丁香婷婷综合久久来来去| 久久综合久久鬼色| 国产亚洲美女精品久久久| 中文字幕无码免费久久| 色青青草原桃花久久综合| 久久久久国产精品麻豆AR影院 | 国产精品亚洲美女久久久| 丁香五月网久久综合| 无遮挡粉嫩小泬久久久久久久 | 久久久久久精品无码人妻| 久久久久免费精品国产| 久久久亚洲欧洲日产国码二区| 久久久久国产精品嫩草影院| 国产免费久久精品丫丫| 99久久精品国产麻豆| 久久亚洲中文字幕精品有坂深雪| 一本色道久久88综合日韩精品| 国产精品综合久久第一页| 久久综合久久综合九色| 久久97精品久久久久久久不卡| 欧美牲交A欧牲交aⅴ久久| 日产精品99久久久久久| 无码人妻少妇久久中文字幕蜜桃| 精品久久久久久无码不卡| 亚洲国产精品嫩草影院久久| 亚洲欧美国产日韩综合久久 | 久久91亚洲人成电影网站| 国产精品无码久久综合 | 久久精品人人槡人妻人人玩AV|