C#¡¢ASP.NETÖÐrefºÍoutµÄÇø±ð
ÕâÁ½¸öÊý¾ÝÀàÐÍÊÇÎÒÃÇÔÚѧϰC#ÓïÑԵĹý³ÌÖÐÊý¾Ý±È½ÏÄѵÄÁ½¸öÊý¾ÝÀàÐÍ£¬²»¹ýËûÃǺÜÖØÒª£¬ËùÒÔÓбØÒªÄóöÀ´ËµËµËûÃǵÄʹÓ÷½·¨ºÍ²»Í¬Ö®´¦£¬Ï£Íû¶ÔÄãÓÐËù°ïÖú¡£
ÏÈ×ܵÄÀ´Ëµ£º
ͨ³£ÎÒÃÇÏò·½·¨Öд«µÝµÄÊÇÖµ.·½·¨»ñµÃµÄÊÇÕâЩֵµÄÒ»¸ö¿½±´,È»ºóʹÓÃÕâЩ¿½±´,µ±·½·¨ÔËÐÐÍê±Ïºó,ÕâЩ¿½±´½«±»¶ªÆú,¶øÔÀ´µÄÖµ²»½«Êܵ½Ó°Ïì.´ËÍâÎÒÃÇ»¹ÓÐÆäËûÏò·½·¨´«µÝ²ÎÊýµÄÐÎʽ,ÒýÓÃ(ref)ºÍÊä³ö(out).
ÓÐʱ,ÎÒÃÇÐèÒª¸Ä±äÔÀ´±äÁ¿ÖеÄÖµ,Õâʱ,ÎÒÃÇ¿ÉÒÔÏò·½·¨´«µÝ±äÁ¿µÄÒýÓÃ,¶ø²»ÊDZäÁ¿µÄÖµ.ÒýÓÃÊÇÒ»¸ö±äÁ¿,Ëû¿ÉÒÔ·ÃÎÊÔÀ´±äÁ¿µÄÖµ,ÐÞ¸ÄÒýÓý«ÐÞ¸ÄÔÀ´±äÁ¿µÄÖµ.±äÁ¿µÄÖµ´æ´¢ÔÚÄÚ´æÖÐ,¿ÉÒÔ´´½¨Ò»¸öÒýÓÃ,ËûÖ¸Ïò±äÁ¿ÔÚÄÚ´æÖеÄλÖÃ.µ±ÒýÓñ»ÐÞ¸Äʱ,Ð޸ĵÄÊÇÄÚ´æÖеÄÖµ,Òò´Ë±äÁ¿µÄÖµ¿ÉÒÔ½«±»ÐÞ¸Ä.µ±ÎÒÃǵ÷ÓÃÒ»¸öº¬ÓÐÒýÓòÎÊýµÄ·½·¨Ê±,·½·¨ÖеIJÎÊý½«Ö¸Ïò±»´«µÝ¸ø·½·¨µÄÏàÓ¦±äÁ¿,Òò´Ë,ÎÒÃÇ»áÃ÷°×,Ϊʲôµ±Ð޸IJÎÊý±äÁ¿µÄÐÞ¸ÄÒ²½«µ¼ÖÂÔÀ´±äÁ¿µÄÖµ.
RefÖ¸Ã÷ÁË·½·¨ÖÐʹÓõÄÊÇÒýÓÃÐͲÎÊý£¬ÒýÓÃÐͲÎÊý²»¿ª±ÙеÄÄÚ´æÇøÓò¡£µ±ÀûÓÃÒýÓÃÐͲÎÊýÏò·½·¨´«µÝÐβÎʱ£¬±àÒë³ÌÐò½«°Ñʵ¼ÊÖµÔÚÄÚ´æÖеĵØÖ·´«µÝ¸Ã·½·¨¡£ÒýÓÃÐͲÎÊýͨ³£ÒѾ³õʼ»¯¡£
Èç
int i=1,j=2;//³õʼ»¯
Swap(ref i,ref j);
OutÊä³öÐͲÎÊýÒ²²»¿ª±ÙеÄÄÚ´æÇøÓò£¬µ«ÓëÒýÓÃÐͲÎÊý²»Í¬µÄÊÇ£¬µ÷Ó÷½·¨Ö®Ç°ÎÞÐè¶Ô±äÁ¿½øÐгõʼ»¯£¬Êä³öÐͲÎÊýÖ÷ÒªÓÃÓÚ´«µÝ·½·¨·µ»ØµÄÊý¾Ý¡£
string name,path;//ûÓгõʼ»¯
File(out name,out path);
Ê×ÏÈÏÈ˵ref:(MSDN)
C# ¹Ø¼ü×Ö | ·½·¨²ÎÊý
·½·¨²ÎÊýÉ쵀 ref ·½·¨²ÎÊý¹Ø¼ü×Öʹ·½·¨ÒýÓô«µÝµ½·½·¨µÄͬһ¸ö±äÁ¿¡£µ±¿ØÖÆ´«µÝ»Øµ÷Ó÷½·¨Ê±£¬ÔÚ·½·¨ÖжԲÎÊýËù×öµÄÈκθü¸Ä¶¼½«·´Ó³ÔڸñäÁ¿ÖС£ÈôҪʹÓà ref ²ÎÊý£¬±ØÐ뽫²ÎÊý×÷Ϊ ref ²ÎÊýÏÔʽ´«µÝµ½·½·¨¡£ref ²ÎÊýµÄÖµ±»´«µÝµ½ ref ²ÎÊý¡£´«µÝµ½ ref ²ÎÊýµÄ²ÎÊý±ØÐë×îÏȳõʼ»¯¡£½«´Ë·½·¨Óë out ²ÎÊýÏà±È£¬ºóÕߵIJÎÊýÔÚ´«µÝµ½ out ²ÎÊý֮ǰ²»±ØÏÔʽ³õʼ»¯¡£
ÊôÐÔ²»ÊDZäÁ¿£¬²»ÄÜ×÷Ϊref ºÍout²ÎÊý´«µÝ¡£
Èç¹ûÁ½ÖÖ·½·¨µÄÉùÃ÷½öÔÚËüÃÇ¶Ô ref µÄʹÓ÷½Ã治ͬ£¬Ôò½«³öÏÖÖØÔØ¡£µ«ÊÇ£¬ÎÞ·¨¶¨Òå½öÔÚ ref ºÍ out ·½Ã治ͬµÄÖØÔØ¡£ÀýÈ磺
//ÒÔÏÂÖØÔØÉùÃ÷ÊÇÓÐЧµÄ£º
class MyClass
{
public void MyMethod(int i) {i = 10;}
public void MyMethod(ref int i) {i = 10;}
}
µ«ÒÔÏÂÖØÔØÉùÃ÷ÊÇÎÞЧ
Ïà¹ØÎĵµ£º
Ö»ÓÐÔÚ¡òPageÖ¸ÁîÖÐÉèÖÃÁË£ºAutoEventWireup="true"£¬·þÎñÆ÷¶ËµÄ±àÒëÆ÷½«°´ÕÕ Page_eventname ·½·¨ÃûµÄÐÎʽ×Ô¶¯µÄ¼ì²éÏàӦʼþ´¦Àí·½·¨£¬×Ô¶¯ÊµÏÖʼþµÄ¶©ÔÄ¡£
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System ......
ÔÚ.netÖÐͨ¹ýÕâÖÖ·½Ê½ÒýÓÃjsÎļþ
<script type="text/javascript" src="setday0.js"></script>
È»ºóÔÚÒ³ÃæÖе÷ÓÃsetday0.jsÎļþÖеķ½·¨ÍùÍù»á³ö´í£¡µ«ÊÇÄãÈç¹û°Ñsetday0.jsÎļþµÄÄÚÈÝÖ±½Ó·Åµ½¸ÃÒ³ÃæÖÐÀ´ÓÖÒ»µãÎÊÌâҲûÓС£Õâ¸öÎÊÌâÀ§»óÁËÎҺܾã¬ÔÚ1.1µÄʱºò¾ÍÓöµ½Á˵±Ê±Ã»°ì·¨¾ÍÔÚÒ³ÃæÖÐÖØдjs´úÂë¡£½ñÌ ......
ÔÌûµØÖ·£ºhttp://www.cnblogs.com/clingingboy/archive/2006/07/30/463471.html
asp.net±¾ÉíÌṩÁ˺ܶà¿Ø¼þ,Ìṩ¸øÎÒÃÇÕâЩ±È½ÏÀÁ¶èµÄÈËʹÓÃ,ÎÒÈÏΪ¿Ø¼þµÄ×÷ÓþÍÔÚ´Ë,ÒòΪÎÒÃDz»ÏëÖظ´¹¤×÷,ËùÒÔÒª´´½¨Ëü,Õâ¸ö±¾Éí±ãÊÇ
Ò»¸öÐèÇóµÄ¹Øϵ,ËùÒÔѧϰ¿Ø¼þ¿ª·¢ºÜÓÐÒâ˼.
wroxÍøÕ¾ÉÏÓб¾Êé Professional ASP.NET 2.0 Server Cont ......
C#Éú³Écom×é¼þ£¬¹©aspµ÷ÓÃ
Ò»¡¢vs2005—н¨ÏîÄ¿—C#Àà¿â
Àà¿âÔ´ÂëÈçÏÂ(°üº¬½Ó¿Ú£¬À࣬ʼþ½Ó¿Ú)£º
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Data.SqlClient;
using System.Runtime.InteropServices;
namespace entryclass
{
  ......