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

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()¶ÔÏó //Ë


Ïà¹ØÎĵµ£º

c# using ¹Ø¼ü×ÖµÄÓ÷¨


ÔÚnetÖÐÓÐÒ»¸öÖÁ¹ØÖØÒªµÄ¹Ø¼ü×Ö£¬ÄǾÍÊÇusing
usingÒ»°ãÓÐ×ÅÒÔϼ¸ÖÖÓ÷¨£º
1¡¢Ö±½ÓÒýÈëÃüÃû¿Õ¼ä
a¡¢using System £¬Õâ¸öÊÇ×î³£Óõ쬾ÍÊÇusing+ÃüÃû¿Õ¼ä£¬ÕâÑù¾Í¿ÉÒÔÖ±½ÓʹÓÃÃüÃû¿Õ¼äÖеÄÀàÐÍ£¬¶øÃâÈ¥ÁËʹÓÃÏêϸµÄÃüÃû¿Õ¼ä
b¡¢Ê¹ÓÃÈ«ÏÞ¶¨Ãû
²»ÓÃʹÓÃusing System;Ö±½ÓÔÚ³ÌÐòÖе÷ÓÃSystem.Console.WriteLine("Hello ......

c# primer note I

------------------------
¡ï
Foreach £º
Óŵ㣺
1¡¢²»Óÿ¼ÂÇÊý×éÆðʼË÷ÒýÊǼ¸
int[] nArray = new int[100];
// Use "foreach" to loop array
foreach( int i in nArray )
2¡¢¶ÔÓÚ¶àάÊý×é²Ù×÷ÓÃforeach·Ç³£¼ò±ã
int[,] nVisited = new int[8,8];
// Use "for" to loop two-dimension array
for( int i = 0; i ......

C#ʵÏÖ³ÌÐòµÄ°æ±¾Éý¼¶¸üÐÂ

   ÎÒÃÇ×öÁ˳ÌÐò£¬²»Ãâ»áÓа汾Éý¼¶£¬Õâ¾ÍÐèÒª³ÌÐòÓÐ×Ô¶¯°æ±¾Éý¼¶µÄ¹¦ÄÜ¡£
ÄÇô¿´¿´ÎÒÊÇÈçºÎʵÏÖ³ÌÐò×Ô¶¯¸üеġ£
Ö±½ÓÉÏ´úÂ룺
 using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.IO;
using System.Net;
using System.Xml;
namespace ......

C#Öм̳ÐʵÏÖ¸¸Àà·½·¨¡¢ÖØÐ´¡¢ÖØÔØ

¼Ì³ÐÊÇÅÉÉúÀࣨ×ÓÀࣩȥʵÏÖ£¨ÖØÐ´<override>¡¢Öع¹<new>£©»ùÀࣨ¸¸ÀࣩµÄ·½·¨»òÊôÐÔ¡£´Ó¶ø»ñÈ¡ÔÚÅÉÉúÀàÖÐҪʵÏֵŦÄÜ¡£
×ÓÀàµ÷Óø¸À๹Ôì·½·¨£¬ÔÚ¸¸ÀàÖÐÓиöʵÏÖÐÕÃûºÍÄêÁäµÄ¹¹Ôì·½·¨µ«ÊÇÖÐ×ÓÀàҲҪʵÏÖÕâÑùµÄ¹¦ÄÜÕâʱ×ÓÀ಻ÓÃÔÙ´ÎȥдÕâ¸ö¹¦ÄÜֻҪȥµ÷Óø¸ÀàµÄ¹¦Äܼ´¿É¡£
public class Person
 & ......

C#ÀûÓÃwinapi¶¨Î»¿Ø¼þλÖÃËã·¨

public struct RECT
{
      public int left;
      public int Top;
      public int Right;
      public int Bottom;
}
public static bool CenterMouseOn(int hwnd)
{
     ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ