C#Êý×éѧϰ
Êý×é¸ÅÊö
C# Êý×é´ÓÁ㿪ʼ½¨Á¢Ë÷Òý£¬¼´Êý×éË÷Òý´ÓÁ㿪ʼ¡£C# ÖÐÊý×éµÄ¹¤×÷·½Ê½ÓëÔÚ´ó¶àÊýÆäËûÁ÷ÐÐÓïÑÔÖеŤ×÷·½Ê½ÀàËÆ¡£µ«»¹ÓÐһЩ²îÒìÓ¦ÒýÆð×¢Òâ¡£
ÉùÃ÷Êý×éʱ£¬·½À¨ºÅ ([]) ±ØÐë¸úÔÚÀàÐͺóÃ棬¶ø²»ÊDZêʶ·ûºóÃæ¡£ÔÚ C# ÖУ¬½«·½À¨ºÅ·ÅÔÚ±êʶ·ûºóÊDz»ºÏ·¨µÄÓï·¨¡£
int[] table; // not int table[];
Áíһϸ½ÚÊÇ£¬Êý×éµÄ´óС²»ÊÇÆäÀàÐ͵ÄÒ»²¿·Ö£¬¶øÔÚ C ÓïÑÔÖÐËüÈ´ÊÇÊý×éÀàÐ͵ÄÒ»²¿·Ö¡£ÕâʹÄú¿ÉÒÔÉùÃ÷Ò»¸öÊý×é²¢ÏòËü·ÖÅä int ¶ÔÏóµÄÈÎÒâÊý×飬¶ø²»¹ÜÊý×鳤¶ÈÈçºÎ¡£
int[] numbers; // declare numbers as an int array of any size
numbers = new int[10]; // numbers is a 10-element array
numbers = new int[20]; // now it's a 20-element array
ÉùÃ÷Êý×é
C# Ö§³ÖһάÊý×é¡¢¶àάÊý×飨¾ØÐÎÊý×飩ºÍÊý×éµÄÊý×飨½»´íµÄÊý×飩¡£ÏÂÃæµÄʾÀýչʾÈçºÎÉùÃ÷²»Í¬ÀàÐ͵ÄÊý×飺
һάÊý×飺
int[] numbers;
¶àάÊý×飺
string[,] names;
Êý×éµÄÊý×飨½»´íµÄ£©£º
byte[][] scores;
ÉùÃ÷Êý×飨ÈçÉÏËùʾ£©²¢²»Êµ¼Ê´´½¨ËüÃÇ¡£ÔÚ C# ÖУ¬Êý×éÊǶÔÏ󣨱¾½Ì³ÌÉÔºóÌÖÂÛ£©£¬±ØÐë½øÐÐʵÀý»¯¡£ÏÂÃæµÄʾÀýչʾÈçºÎ´´½¨Êý×飺
һάÊý×飺
int[] numbers = new int[5];
¶àάÊý×飺
string[,] names = new string[5,4];
Êý×éµÄÊý×飨½»´íµÄ£©£º
byte[][] scores = new byte[5][];
for (int x = 0; x < scores.Length; x++)
{
scores[x] = new byte[4];
}
»¹¿ÉÒÔÓиü´óµÄÊý×é¡£ÀýÈ磬¿ÉÒÔÓÐÈýάµÄ¾ØÐÎÊý×飺
int[,,] buttons = new int[4,5,3];
ÉõÖÁ¿ÉÒÔ½«¾ØÐÎÊý×éºÍ½»´íÊý×é»ìºÏʹÓá£ÀýÈ磬ÏÂÃæµÄ´úÂëÉùÃ÷ÁËÀàÐÍΪ int µÄ¶þάÊý×éµÄÈýάÊý×éµÄһάÊý×é¡£
int[][,,][,] numbers;
³õʼ»¯Êý×é
C# ͨ¹ý½«³õʼֵÀ¨ÔÚ´óÀ¨ºÅ ({}) ÄÚΪÔÚÉùÃ÷ʱ³õʼ»¯Êý×éÌṩÁ˼òµ¥¶øÖ±½ÓÁ˵±µÄ·½·¨¡£ÏÂÃæµÄʾÀýչʾ³õʼ»¯²»Í¬ÀàÐ͵ÄÊý×éµÄ¸÷ÖÖ·½·¨¡£
×¢Òâ Èç¹ûÔÚÉùÃ÷ʱûÓгõʼ»¯Êý×飬ÔòÊý×é³ÉÔ±½«×Ô¶¯³õʼ»¯Îª¸ÃÊý×éÀàÐ͵ÄĬÈϳõʼֵ¡£ÁíÍ⣬Èç¹û½«Êý×éÉùÃ÷ΪijÀàÐ͵Ä×ֶΣ¬Ôòµ±ÊµÀý»¯¸ÃÀàÐÍʱËü½«±»ÉèÖÃΪĬÈÏÖµ null¡£
һάÊý×é
int[] numbers = new int[5] {1, 2, 3, 4, 5};
string[] names = new string[3] {"Matt", "Joanne", "Robert"};
¿ÉÊ¡ÂÔÊý×éµÄ´óС£¬ÈçÏÂËùʾ£º
int[] numbers = new int[] {1, 2, 3, 4, 5};
string[] names = new string[] {"Matt", "Joan
Ïà¹ØÎĵµ£º
C# accessÈÕÆÚ²éѯ¼Ó#
if (((string)((ComboBoxItem)cmbField.SelectedItem).Value).Equals("System.DateTime"))
{
//ÅжÏÈÕÆÚµÄ;
& ......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
namespace ½«Ã¶¾Ù×÷Ϊ¼üÖµµÄÐÎʽ´æ´¢
{
enum Myenum
{
First=3,
Second ......
Õâ¸öÎÊÌâÒ²²»ÖªµÀÄѵ¹Á˶àÉÙC#ºÀ½Ü¡£±ÈÆðMFCµÄ½çÃæˢУ¬ÔÚWINFORMÖÐÀ´ÊµÏÖ¶àÏß³ÌË¢ÐÂÕæÊǺÜÍ´¿à£¬¹Êд´ËÎÄ¡£
¶àÏß³ÌˢнçÃæÖ÷ÒªÓõ½¶àỊ̈߳¬Î¯ÍУ¬Ḭ̈߳²È«¡¢Ê¼þµÈһϵÁиßÄѶȵÄC#²Ù×÷¡£
¹ØÓÚίÍкÍʼþ£¬ÕâÓÐһƪºÜÒ׶®µÄÎÄÕ£ºhi.baidu.com/anglecloudy/blog/item/a52253ee804d052f2df534ab.html
£½£½£½£½£½£½£½£½ ......
ÍêÉÆÁË“ÈçºÎÔÚC#ÖÐʹÓÃWin32ºÍÆäËû¿â”ÖйØÓÚEnumDesktops()º¯ÊýµÄ»Øµ÷´úÂ룬¿ÉÔËÐС£
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
class Program
{
delegate bool EnumDesk ......
µÚÒ»Õ ³ÌÐòÉè¼Æ
¡¡¡¡“ÒªÏë³ÉΪÕæÕýµÄ³ÌÐòÔ±£¬ÎÒÃÇÐèÒª½øÐÐÒ»³¡Ï´Àñ¡£”
¡¡¡¡“³ÌÐò = Êý¾Ý½á¹¹ + Ëã·¨¡£”ÕâÑùµÄ¹«Ê½ºÜ¾«±Ù£¬ËüÔ½¹ýÁ˱í²ãÖ±½ÓÃèÊöÁ˳ÌÐòµÄ±¾ÖÊ¡£²»½öÈç´Ë£¬ÕâÑù¼¸¸ö¼òµ¥µÄµ¥´ÊÒ²ÈÃÎÒÃÇÃ÷°×“ÎÒÃÇÓ¦¸ÃѧϰʲôÄÚÈÝ£¿”¡£ÈËÃÇ×öÈκÎʶ¼ÓÐÒ»¶¨µÄ³ÌÐò£¬Ö»ÊÇûÓÐÒâÊ ......