C#ÖÐrefºÍoutµÄÇø±ð
¿´Á˺ܶà.°´ÕÕ ×Ô¼ºÃ÷°×½âÊÍһϠ.NET RefºÍOut¹Ø¼ü×Ö ¶ÔÓÚÖµÀàÐÍ¡£ Èç¹û²»Ê¹ÓÃref /outÔò´«µÝµÄÖ»ÊÇÕâЩֵµÄCOPY, ʹÓÃÁËRefºÍOutµÄЧ¹û¾Í¼¸ºõºÍCÖÐʹÓÃÁËÖ¸Õë±äÁ¿Ò»Ñù¡£(´«µÝµÄ¾ÍÊÇÔÖµ),ËüÄܹ»ÈÃÄãÖ±½Ó¶ÔÔÊý½øÐвÙ×÷£¬¶ø²»ÊǶÔÄǸöÔÊýµÄCopy½øÐвÙ×÷ ¶ÔÓÚÒýÓÃÀàÐÍ: Èç¹û²»Ê¹ÓÃref /out,ÒòΪ´«µÝµÄÊÇÒýÓÃÀàÐ͵ĵØÖ·Öµ,Ôò½«´«µÝÒýÓÃÀàÐ͵ĵØÖ·ÖµµÄÒ»¸öCOPY(--Õë¶ÔµØÖ·ÖµµÄ½Ç¶È»¹ÊÇÖµÀàÐÍ´«µÝ),ʵ¼ÊÉϾÍÊÇпªÒ»¸ö²»Í¬µÄÄÚ´æ±äÁ¿À´´æ´¢Õâ¸öµØÖ·ÖµµÄ¿½±´ ¶øÊ¹ÓÃref /out,´«µÝµÄ»¹ÊÇÒýÓÃÀàÐ͵ĵØÖ·Öµ,µ«ÊÇ´«µÝµÄ¾Í²»ÊÇÒ»¸öбäÁ¿À´´æ¿½±´,¶øÊǾÍÊÇ´«ÔÀ´µÄÄǸöÓ¦ÓÃÀàÐ͵ĵØÖ·Öµ /////////////////×¢ÒâlistµÄ´¦Àí////////²»ÓùØÐÄ,Òì²½,´úÀíίÍÐÕâЩ;¿ÉÒÔºÍʹÓÃͬ²½·½·¨Ò»ÑùÀí½â£»Ö»ÊÇÕýºÃÓöµ½ÁËÕâ¸öÀý////////////////////////////////////////////////×ÓËùÒÔÄÃÀ´Óã» public delegate string DelegateWithParameters(string param1, int param2, ArrayList list); private void CallFooWithParameters() { // create the paramets to pass to the function string strParam1 = "Param1"; int intValue = 100; ArrayList list = new ArrayList(); list.Add("Item1"); // create the delegate DelegateWithParameters delFoo = new DelegateWithParameters(FooWithParameters); // call FooWithParameters(string param1,int param2, ArrayList list) // ʵ¼ÊÉÏlistµÄÒýÓõØÖ·×÷ΪֵÀàÐÍ´«µÝ,½øÈë·½·¨Ê±,ÓÃÒ»¸öÐÂÄÚ´æ±äÁ¿´æ´¢Õâ¸öÒýÓõĵØÖ· //ËùÒÔÔÚº¯ÊýÄÚ²¿¶à¸ÃÐÂÄÚ´æ±äÁ¿µØÖ·ÐÞ¸Ä.Ö»ÊÇÈøÃÐÂÄÚ´æ±äÁ¿Ö¸ÏòÁËÁíÍâÒ»¸ölist IAsyncResult tag = delFoo.BeginInvoke(strParam1, intValue, list, null, null); // normally control is returned right away, // so you can do other work here... // calling end invoke to get the return value string strResult = delFoo.EndInvoke(tag); // write down the parameters: Trace.WriteLine("param1: " + strParam1); Trace.WriteLine("param2: " + intValue); Trace.WriteLine("ArrayList count: " + list.Count); } private string FooWithParameters(string param1, int param2, ArrayList list) { // lets modify the data! param1 = "Modify Value for param1"; param2 = 200; list = new ArrayList(); //listÊÇ´«½øÀ´µÄÄǸöµØÖ·µÄ¿½±´;ËùÒÔÖ»ÊǰÑÕâ¸öеĿ½±´Ö¸ÏòÁËÒ»¸öеÄnew ArralyList()¶ÔÏó //Ë
Ïà¹ØÎĵµ£º
ÒÑÖªÓÐÒ»¸öXMLÎļþ£¨bookstore.xml£©ÈçÏ£º
<?xml version="1.0" encoding="gb2312"?>
<bookstore>
<book genre="fantasy" ISBN="2-3631-4">
<title>Oberon's Legacy</title>
<author>Corets, Eva</author>
&nb ......
C#ÕýÔò±í´ïʽ±à³Ì£¨Èý£©£ºMatchÀàºÍGroupÀàÓ÷¨ ÊÕ²Ø ´ËÎÄÓÚ2010-03-09±»ÍƼöµ½CSDNÊ×Ò³
ÈçºÎ±»ÍƼö£¿
Ç°ÃæÁ½Æª½²ÊöÁËÕýÔò±í´ïʽµÄ»ù´¡ºÍһЩ¼òµ¥µÄÀý×Ó£¬ÕâÆª½«ÉÔ΢ÉîÈëÒ»µã̽ÌÖÒ»ÏÂÕýÔò±í´ïʽ·Ö×飬ÔÚ.NETÖÐÕýÔò±í´ïʽ·Ö×éÊÇÓÃMathÀàÀ´´ú±íµÄ¡£
Ê×ÏÈÏÈ¿´Ò»¶Î´úÂ룺
view plaincopy to clipboardprint?
/// &l ......
Ò»¡¢³éÏóÀࣺ
³éÏóÀàÊÇÌØÊâµÄÀֻ࣬ÊDz»Äܱ»ÊµÀý»¯£»³ý´ËÒÔÍ⣬¾ßÓÐÀàµÄÆäËûÌØÐÔ£»ÖØÒªµÄÊdzéÏóÀà¿ÉÒÔ°üÀ¨³éÏó·½·¨£¬ÕâÊÇÆÕͨÀàËù²»Äܵġ£³éÏó·½·¨Ö»ÄÜÉùÃ÷ÓÚ³éÏóÀàÖУ¬ÇÒ²»°üº¬ÈκÎʵÏÖ£¬ÅÉÉúÀà±ØÐ븲¸ÇËüÃÇ¡£ÁíÍ⣬³éÏóÀà¿ÉÒÔÅÉÉú×ÔÒ»¸ö³éÏóÀ ......
private static int level=0
public static int FindGUILike(ref int hWndArray,int hWndStart,ref string windowText,ref string className,ref string parentText)
{
int hwnd=0;
int r=0;
StringBuilder sWindowText=new StringBuilder();
StringBuilder sClassname=new StringBuilder();
StringBuilder sParentT ......
ÎÒÃÇ×öÁ˳ÌÐò£¬²»Ãâ»áÓа汾Éý¼¶£¬Õâ¾ÍÐèÒª³ÌÐòÓÐ×Ô¶¯°æ±¾Éý¼¶µÄ¹¦ÄÜ¡£
ÄÇô¿´¿´ÎÒÊÇÈçºÎʵÏÖ³ÌÐò×Ô¶¯¸üеġ£
Ö±½ÓÉÏ´úÂ룺
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;
using System.Net;
using System.Xml;
namespace ......