Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

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;}
}
µ«ÒÔÏÂÖØÔØÉùÃ÷ÊÇÎÞЧ


Ïà¹ØÎĵµ£º

ASP.NETÅäÖÃÎļþWeb.config

(Ò»).Web.ConfigÊÇÒÔXMLÎļþ¹æ·¶´æ´¢,ÅäÖÃÎļþ·ÖΪÒÔϸñʽ
1.ÅäÖýڴ¦Àí³ÌÐòÉùÃ÷
Ìص㣺 λÓÚÅäÖÃÎļþµÄ¶¥²¿£¬°üº¬ÔÚ<configSections>±êÖ¾ÖС£
2.Ìض¨Ó¦ÓóÌÐòÅäÖÃ
Ìصã: λÓÚ<appSetting>ÖС£ ¿ÉÒÔ¶¨ÒåÓ¦ÓóÌÐòµÄÈ«¾Ö³£Á¿ÉèÖõÈÐÅÏ¢.
3.ÅäÖýÚÉèÖÃ
Ìصã: λÓÚ<system.Web>½ÚÖУ¬¿ØÖÆAsp.netÔËÐÐÊ ......

ASP.NET´´½¨¿ì½Ý·½Ê½

  using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class ......

ASP.NETÓ¦ÓóÌÐòÁ¬½ÓOracleµÄÎÊÌâ

ÔÙWindows XPÉÏдºÃµÄASP.NETÓ¦ÓóÌÐò²¿Êðµ½IISÉÏ,Á¬½Ó²»ÉÏOracle10gÊý¾Ý¿â,Ìáʾ£º
System.Data.OracleClient Requires oracle client software version 8.1.7 or greater¡£
ÒòΪÔÚµ÷ÊÔ»·¾³ÊÇ¿ÉÒÔÁ¬½ÓÉϵÄ,ËùÒÔ¿¼ÂÇ¿ÉÄÜÊÇIISȨÏÞÉèÖÃÎÊÌâ¡£
ÊÔ׎«ASP.NETÓû§Ìí¼Óµ½ÁËAdministrator×éÖС£½á¹ûÁ¬½Ó³É¹¦¡£ ......

C#Éú³Écom×é¼þ£¬¹©aspµ÷ÓÃ

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
{
   ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ