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 < nVisited.GetLength(0); i++ )
for( int j = 0; j < nVisited.GetLength( 1 ); j++ )
Debug.WriteLine( nVisited[i,j].ToString() );
// Use "foreach" to loop two-dimension array
foreach( int i in nVisited )
Debug.WriteLine( i.ToString() );
3¡¢foreachÀàÐÍת»»
// Init an arraylist object
int[] nArray = new int[100];
ArrayList arrInt = new ArrayList();
arrInt.AddRange( nArray );
// Use "foreach" to loop an arraylist
foreach( int i in arrInt )
Debug.WriteLine( i.ToString() );
// Use "for" to loop an arraylist
for( int i = 0; i < arrInt.Count; i++ )
{
int n = ( int ) arrInt[i];
Debug.WriteLine( n.ToString() );
}
Á½¸öÏÞÖÆ
ÔÚforeach²»ÄÜÐÞ¸Äö¾Ù³ÉÔ±£¬Æä´Î²»Òª¶Ô¼¯ºÏ½øÐÐɾ³ý²Ù×÷¡£
// Use "foreach" to loop an arraylist
foreach( int i in arrInt )
{
i++;//Can't be compiled
Debug.WriteLine( i.ToString() );
}
// Use "foreach" to loop an arraylist
foreach( int i in arrInt )
{
arrInt.Remove( i );//It will generate error in run-time
Debug.WriteLine( i.ToString() );
}
¸½--¶ÔÓڼǼ¼¯µÄ¶àÌõÊý¾Ýɾ³ý
¿ÉÒÔÓÃforÀ´ÊµÏÖ£¬ÓÉÓÚÔÚһЩ¼Ç¼¼¯ÖнøÐÐɾ³ýµÄʱºò£¬ÔÚɾ³ý²Ù×÷Ö®ºóÏàÓ¦µÄË÷ÒýÒ²·¢ÉúÁ˱仯£¬ÕâʱºòµÄɾ³ýÒª·´¹ýÀ´½øÐÐɾ³ý
// Use "for" to loop an arraylist
for( int i = arrInt.Count - 1; i >=0; i-- )
{
int n = ( int ) arrInt[i];
if( n == 5 )
arrInt.RemoveAt( i ); // Remove data here
Debug.WriteLine( n.ToString() );
}
http://blog.csdn.net/huang7914/archive/2008/04/16/2296176.aspx
------------------------
¡ï
------------------------
¡ï
------------------------
¡ï
------------------------
¡ï
------------------------
¡ï
------------------------
¡ï
------------------------
¡ï
---------------------
Ïà¹ØÎĵµ£º
һֱûÓÐÕÒµ½Ò»Öֺõķ½·¨À´ÒýÓÃÓзµ»ØÖµµÄ´æ´¢¹ý³ÌµÄ·½·¨£¬Ê¹ÎÒÔÚÌí¼ÓÊý¾ÝÖÐ×ßÁ˲»ÉÙµÄÍä·£¬×î½ü£¬ÔÚ²éÔÄÁË´óÁ¿µÄ×ÊÁÏÖ®ºó£¬ÖÕÓÚÔÚ΢ÈíµÄÒ»¸öʵÀýÖÐÕÒµ½ÁËÒ»ÖÖÁ¼ºÃµÄ·½·¨¡£
Ê×ÏȱàдºÃÒ»Óзµ»ØÖµµÄ´æ´¢¹ý³Ì
create procedure proc_name
@para1 nchar(20), --ÊäÈë²ÎÊý
@ ......
·Ç³£¼òµ¥,ÔÚC#ÖÐÖ»ÐèÒªÔÚÀàµÄ·½·¨µÄÉÏ·½ÇÃÈýÏÂ"/"¾Í×Ô¶¯°ïÄãÌí¼ÓÏà¹ØµÄ´úÂë,ÄãÖ»Òª°´×ÅÌîд¾Í¿ÉÒÔÁË,¶øJavaÔòÊÇÊäÈë"/**",ËüÒ²»á×Ô¶¯ÐγÉÏà¹Ø´úÂë,¾ßÌå´úÂëÈçÏÂ:
C#
/// <summary>
/// ÔÚ´ËÌîд×ÜÌåÃèÊö
///</summary>
/// <param name="name">ÕâÀïÌîд²ÎÊýnameµÄÃèÊö</param>
public string ......
½üÀ´ORM±äµÃÔ½À´Ô½Æձ飬Õⶼ¹éÓÚÒ»Öֺܾß˵·þÁ¦µÄÔÒò£»Ëü¿ÉÒÔʹ¿ª·¢Êý¾Ý¿âÇý¶¯µÄÓ¦ÓóÌÐò±äµÃ¸ü¿ì¡¢¸üÊ¡Á¦¡£µ«ÊÇORM¿ò¼Ü¶¼Óе㓹ÌÖ´¼º¼û”£¬ËûÃÇÆÚÍû¿ª·¢Õß×ñ´ÓÌض¨µÄ¹æÔò£¬µ±¹æÔò±»´òÆƵÄʱºò¾Í·Ç³£ÄÑÒÔʹÓá£×îͨ³£µÄ¹æÔòÖ®Ò»¾ÍÊÇ£¬´æ´¢¹ý³Ì±ØÐë×ÜÊÇ·µ»Øµ¥¶ÀµÄ½á¹û¼¯£¬ÆäÖд ......
ÔÚnetÖÐÓÐÒ»¸öÖÁ¹ØÖØÒªµÄ¹Ø¼ü×Ö£¬ÄǾÍÊÇusing
usingÒ»°ãÓÐ×ÅÒÔϼ¸ÖÖÓ÷¨£º
1¡¢Ö±½ÓÒýÈëÃüÃû¿Õ¼ä
a¡¢using System £¬Õâ¸öÊÇ×î³£Óõģ¬¾ÍÊÇusing+ÃüÃû¿Õ¼ä£¬ÕâÑù¾Í¿ÉÒÔÖ±½ÓʹÓÃÃüÃû¿Õ¼äÖеÄÀàÐÍ£¬¶øÃâÈ¥ÁËʹÓÃÏêϸµÄÃüÃû¿Õ¼ä
b¡¢Ê¹ÓÃÈ«ÏÞ¶¨Ãû
²»ÓÃʹÓÃusing System;Ö±½ÓÔÚ³ÌÐòÖе÷ÓÃSystem.Console.WriteLine("Hello ......
public enum GUIInfoType
{
guiText.
guiTextClass,
guiTextParent,
guiTextClassParent,
}
private static int level=0
public static int FindGUILike(ref int hWndArray,int hWndStart,ref string window ......