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

C#ɨÃè¼ÆËã»ú¶Ë¿Ú

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace PortScanner
{
class Program
{
¡¡//ÒÑɨÃè¶Ë¿ÚÊýÄ¿
¡¡internal static int scannedCount = 0;
¡¡//ÕýÔÚÔËÐеÄÏß³ÌÊýÄ¿
¡¡internal static int runningThreadCount = 0;
¡¡//´ò¿ªµÄ¶Ë¿ÚÊýÄ¿
¡¡internal static List<int> openedPorts = new List<int>();
¡¡//ÆðʼɨÃè¶Ë¿Ú
¡¡static int startPort = 1;
¡¡//½áÊø¶Ë¿ÚºÅ
¡¡static int endPort = 500;
¡¡//×î´ó¹¤×÷Ïß³ÌÊý
¡¡static int maxThread = 10;
¡¡static void Main(string[] args)
¡¡{
¡¡¡¡//½ÓÊÕ´«Èë²ÎÊýÒ»×÷ΪҪɨÃèµÄÖ÷»ú
¡¡¡¡string host = "192.168.0.1";
¡¡¡¡//½ÓÊÕ´«Èë²ÎÊý¶þ×÷Ϊ¶Ë¿ÚɨÃ跶Χ£¬Èç1-4000
¡¡¡¡string portRange = "1-400";
¡¡¡¡startPort = int.Parse(portRange.Split('-')[0].Trim());
¡¡¡¡endPort = int.Parse(portRange.Split('-')[1].Trim());
¡¡¡¡for (int port = startPort; port < endPort; port++)
¡¡¡¡{
¡¡¡¡¡¡//´´½¨É¨ÃèÀà
¡¡¡¡¡¡Scanner scanner = new Scanner(host, port);
¡¡¡¡¡¡Thread thread = new Thread(new ThreadStart(scanner.Scan));
¡¡¡¡¡¡thread.Name = port.ToString();
¡¡¡¡¡¡ thread.IsBackground = true;
¡¡¡¡¡¡//Æô¶¯É¨ÃèÏß³Ì
¡¡¡¡¡¡thread.Start();
¡¡¡¡¡¡runningThreadCount++;
¡¡¡¡¡¡Thread.Sleep(10);
¡¡¡¡¡¡//Ñ­»·£¬Ö±µ½Ä³¸öÏ̹߳¤×÷Íê±Ï²ÅÆô¶¯ÁíÒ»ÐÂỊ̈߳¬Ò²¿ÉÒÔ½Ð×öÍÆÀ­´°¼¼Êõ
¡¡¡¡¡¡while (runningThreadCount >= maxThread) ;
¡¡¡¡}
¡¡¡¡//¿ÕÑ­»·£¬Ö±µ½ËùÓж˿ÚɨÃèÍê±Ï
¡¡¡¡while (scannedCount + 1 < (endPort - startPort)) ;
¡¡¡¡¡¡Console.WriteLine();
¡¡¡¡¡¡Console.WriteLine();
¡¡¡¡¡¡//Êä³ö½á¹û
¡¡¡¡¡¡Console.WriteLine("Scan for host: {0} has been completed , \n total {1} ports scanned, \nopened ports :{2}",
host, (endPort - startPort), openedPorts.Count);
¡¡¡¡foreach (int port in openedPorts)
¡¡¡¡¡¡Console.WriteLine("\tPort: {0} is open", port.ToString().PadLeft(6));
¡¡}
}
//ɨÃèÀà
class Scanner
{
¡¡string m_host;
¡¡int m_port;
¡¡
¡¡public Scanner(string host, int port)
¡¡{
¡¡¡¡m_h


Ïà¹ØÎĵµ£º

C# ¿É·ÃÎÊÐÔÔ¼Êø

C# ÓïÑÔÖеÄÓÐЩ¹¹ÔìÒªÇóij¸öÀàÐÍÖÁÉÙÓëij¸ö³ÉÔ±»òÆäËûÀàÐ;ßÓÐͬÑùµÄ¿É·ÃÎÊÐÔ (at least as accessible as)¡£Èç¹û T µÄ¿É·ÃÎÊÓòÊÇ M ¿É·ÃÎÊÓòµÄ³¬¼¯£¬ÎÒÃǾÍ˵ÀàÐÍ T ÖÁÉÙÓë³ÉÔ±»òÀàÐÍ M ¾ßÓÐͬÑùµÄ¿É·ÃÎÊÐÔ¡£»»ÑÔÖ®£¬Èç¹û T ÔÚ¿É·ÃÎÊ M µÄËùÓÐÉÏÏÂÎÄÖж¼ÊÇ¿É·ÃÎʵģ¬Ôò T ÖÁÉÙÓë M ¾ßÓÐͬÑùµÄ¿É·ÃÎÊÐÔ¡£
´æÔÚÏÂÁпɷÃÎÊÐ ......

C#ÖÐref²ÎÊýÓëout²ÎÊýµÄÇø±ð

ÏÈÌù´úÂë
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Ref_and_Out_test
{
    class Program
    {
        static void Main(string[] args)
      & ......

C#ÖÐString.EmptyÓë""

    ÕâÁ½¸öÔÚÒ»°ãÇé¿öÏÂÊÇÏàµÈµÄ£¬µ«ÊÇϵͳ´¦Àí»úÖÆÉÏÈ´ÓÐËù²»Í¬¡£
    ""»áÔÚÄÚ´æÀï»®Ò»¿é³¤¶ÈΪ0µÄ´æ´¢¿Õ¼ä£¬¶øString.EmptyÄÚ´æ²¢²»ÎªËü·ÖÅä¿Õ¼ä£¬ËùÒÔÎÞÂÛÐÔÄÜ»¹ÊÇËÙ¶ÈÉÏString.Empty¶¼ÓÅÓÚ""¡£
    Ôø¾­¿´¹ýһƪÅжÏ×Ö·û´®¿ÕÖµµÄÐÔÄÜÎÄÕ£¬ÀÏÍâдµÄ¹úÈË·­Ò룬ÎÄÕ´óÒâ ......

c# enmu ö¾ÙС½á(1)

 
ö¾Ù
¡¡¡¡Ã¶¾ÙÀàÐÍÉùÃ÷Ϊһ×éÏà¹ØµÄ·ûºÅ³£Êý¶¨ÒåÁËÒ»¸öÀàÐÍÃû³Æ¡£Ã¶¾ÙÓÃÓÚ“¶àÏîÑ¡Ôñ”³¡ºÏ£¬¾ÍÊdzÌÐòÔËÐÐʱ´Ó±àÒëʱÒѾ­É趨µÄ¹Ì¶¨ÊýÄ¿µÄ“Ñ¡Ôñ”ÖÐ×ö³ö¾ö¶¨¡£
¡¡¡¡Ã¶¾ÙÀàÐÍ£¨Ò²³ÆΪö¾Ù£©Îª¶¨ÒåÒ»×é¿ÉÒÔ¸³¸ø±äÁ¿µÄÃüÃûÕûÊý³£Á¿ÌṩÁËÒ»ÖÖÓÐЧµÄ·½·¨¡£ÀýÈ磬¼ÙÉèÄú±ØÐ붨ÒåÒ»¸ö±äÁ¿£¬¸Ã±äÁ¿ ......

C#ÈëÃÅ

±äÁ¿¡¢³£Á¿¼°±í´ïʽ±äÁ¿ºÍ³£Á¿±äÁ¿(¾²Ì¬¡¢·Ç¾²Ì¬¡¢Êý×éÔªËØ¡¢Öµ²ÎÊý¡¢ÒýÓòÎÊý¡¢Êä³ö²ÎÊý¡¢¾Ö²¿±äÁ¿)¾²Ì¬(static) Èç public static int x;  Ò»µ©¾²Ì¬±äÁ¿ËùÊôµÄÀà±»×°ÔØ£¬Ö±µ½°üº¬¸ÃÀàµÄ³ÌÐòÔËÐнáÊøʱËüÒ»Ö±´æÔÚ¡£·Ç¾²Ì¬£º²»´øÓÐstaticÐÞÊηûÉùÃ÷µÄ±äÁ¿³ÆΪʵÀý±äÁ¿£¬Èçint a ;³£Á¿(attributes constnt-modifiers CO ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ