当前位置: 首页>>代码示例>>C#>>正文


C# Byte.GetLength方法代码示例

本文整理汇总了C#中System.Byte.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Byte.GetLength方法的具体用法?C# Byte.GetLength怎么用?C# Byte.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Byte的用法示例。


在下文中一共展示了Byte.GetLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RC4

        private static void RC4(ref Byte[] bytes, Byte[] key)
        {
            Byte[] s = new Byte[256];
            Byte[] k = new Byte[256];
            Byte temp;
            int i, j;

            for (i = 0; i < 256; i++)
            {
                s[i] = (Byte)i;
                k[i] = key[i % key.GetLength(0)];
            }

            j = 0;
            for (i = 0; i < 256; i++)
            {
                j = (j + s[i] + k[i]) % 256;
                temp = s[i];
                s[i] = s[j];
                s[j] = temp;
            }

            i = j = 0;
            for (int x = 0; x < bytes.GetLength(0); x++)
            {
                i = (i + 1) % 256;
                j = (j + s[i]) % 256;
                temp = s[i];
                s[i] = s[j];
                s[j] = temp;
                int t = (s[i] + s[j]) % 256;
                bytes[x] ^= s[t];
            }
        }
开发者ID:xingkongtianyu,项目名称:Apex-Crypter,代码行数:34,代码来源:Xor.cs

示例2: serialPort_DataReceived

        private void serialPort_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
        {
            // シリアルポートからデータ受信
            {
                Byte[] buff = new Byte[serialPort.BytesToRead];
                serialPort.Read(buff, 0, buff.GetLength(0));

                // 受信サイズの10バイトたまるまで、受け取る
                for (int i = 0; i < buff.Length; i++)
                {
                    sirialResvPool[resvIdx + i] = buff[i];
                }
                resvIdx += buff.Length;
            }

            // 10バイト受け取るまで待つ
            if (resvIdx < 10) return;
            resvIdx = 0;

            try
            {
                for (int i = 0; i < 10; i++)
                {
                    resiveStr += ((int)sirialResvPool[i]).ToString() + " ";
                }
            }
            catch
            {
            }
        }
开发者ID:terakenxx,项目名称:TukubaChallenge,代码行数:30,代码来源:DriveIOport.cs

示例3: Main

        static void Main(string[] args)
        {
            string data = "";
            byte[] sendBytes = new Byte[1024];
            byte[] rcvPacket = new Byte[1024];
            UdpClient client = new UdpClient();
            IPAddress address = IPAddress.Parse(IPAddress.Broadcast.ToString());
            client.Connect(address, 8008);
            IPEndPoint remoteIPEndPoint = new IPEndPoint(IPAddress.Any, 0);

            Console.WriteLine("Client is Started");
            Console.WriteLine("Type your message");

            while (data != "q")
            {
                data = Console.ReadLine();
                sendBytes = Encoding.ASCII.GetBytes(DateTime.Now.ToString() + " " + data);
                client.Send(sendBytes, sendBytes.GetLength(0));
                rcvPacket = client.Receive(ref remoteIPEndPoint);

                string rcvData = Encoding.ASCII.GetString(rcvPacket);
                Console.WriteLine("Handling client at " + remoteIPEndPoint + " - ");

                Console.WriteLine("Message Received: " + rcvPacket.ToString());
            }
            Console.WriteLine("Close Port Command Sent");  //user feedback
            Console.ReadLine();
            client.Close();  //close connection
        }
开发者ID:jonathankellermann,项目名称:UDP_Client,代码行数:29,代码来源:Program.cs

示例4: RC4

        public static void RC4(ref Byte[] bytes, Byte[] key)
        {
            Byte[] result = new byte[256];
            Byte[] s = new Byte[256];
            Byte[] k = new Byte[256];
            Byte temp;

            int i, j;
            int n = key.Length;
            for (i = 0; i < 256; i++)
            {
                s[i] = (Byte)i;
                //k[i] = key[i % key.GetLength(0)];
                k[i] = key[i % n];
            }

            j = 0;
            for (i = 0; i < 256; i++)
            {
                j = (j + s[i] + k[i]) % 256;
                temp = s[i];
                s[i] = s[j];
                s[j] = temp;
            }

            i = 0; j = 0;
            for (int x = 0; x < bytes.GetLength(0); x++)
            {
                i = (i + 1) % 256;
                j = (j + s[i]) % 256;
                temp = s[i];
                s[i] = s[j];
                s[j] = temp;

                int t = (s[i] + s[j]) % 256;
                bytes[x] ^= s[t];
                //Salida en hex
                //Console.Write("{0:X2}", (bytes[x]));
                //Salida caracteres imprimibles
                if (string.IsNullOrEmpty(outFileName))
                {
                    if ((bytes[x] < 32) | (bytes[x] == 129) | (bytes[x] == 141)
                        | (bytes[x] == 143) | (bytes[x] == 144) | (bytes[x] == 157)
                        | (bytes[x] == 159))
                    {
                        Console.Write(".");
                    }
                    else
                    {
                        Console.Write(Encoding.Default.GetString(bytes, x, 1));
                    }
                }
            }
            //Salida a archivo
            if (!string.IsNullOrEmpty(outFileName)) { File.WriteAllBytes(outFileName, bytes); }
        }
开发者ID:ignacioj,项目名称:RC4_Encrypt-Decrypt,代码行数:56,代码来源:rc4encrypt.cs

示例5: ExecShellcode

    private static void ExecShellcode()
    {
        // Convert shellcode string to byte array
        Byte[] sc_bytes = new Byte[shellcode.Length];
        for (int i = 0; i < shellcode.Length; i++)
        {
            sc_bytes [i] = (Byte) shellcode [i];
        }

        // Prevent garbage collector from moving the shellcode byte array
        GCHandle pinnedByteArray = GCHandle.Alloc(sc_bytes, GCHandleType.Pinned);

        // Get handle for shellcode address and address of the page it is located in
        IntPtr shellcodePtr = pinnedByteArray.AddrOfPinnedObject();
        IntPtr shellcodePagePtr = GetPageBaseAddress(shellcodePtr);
        Int32 shellcodeOffset = (Int32)shellcodePtr - (Int32)shellcodePagePtr;
        Int32 shellcodeLen = sc_bytes.GetLength (0);

        // Some debugging information
        Console.WriteLine ("Page Size: {0}", PAGE_SIZE.ToString ());
        Console.WriteLine ("Shellcode address: 0x{0}", shellcodePtr.ToString("x"));
        Console.WriteLine ("First page start address: 0x{0}",
            shellcodePagePtr.ToString("x"));
        Console.WriteLine ("Shellcode offset: {0}", shellcodeOffset);
        Console.WriteLine ("Shellcode length: {0}", shellcodeLen);

        // Make shellcode memory executable
        MakeMemoryExecutable(shellcodePagePtr);

        // Check if shellcode spans across more than 1 page; make all extra pages
        // executable too
        Int32 pageCounter = 1;
        while (shellcodeOffset + shellcodeLen > PAGE_SIZE)
        {
            shellcodePagePtr =
                GetPageBaseAddress(shellcodePtr + pageCounter * PAGE_SIZE);
            pageCounter++;
            shellcodeLen -= PAGE_SIZE;

            MakeMemoryExecutable(shellcodePagePtr);
        }

        // Debug information
        Console.WriteLine ("Pages taken by the shellcode: {0}",
            pageCounter);

        // Make shellcode callable by converting pointer to delegate
        ShellcodeFuncPrototype shellcode_func =
            (ShellcodeFuncPrototype) Marshal.GetDelegateForFunctionPointer(
                shellcodePtr, typeof(ShellcodeFuncPrototype));

        shellcode_func(); // Execute shellcode

        pinnedByteArray.Free();
    }
开发者ID:reider-roque,项目名称:reed,代码行数:55,代码来源:scframe.cs

示例6: TestData

        public void TestData()
        {
            Byte[,] data = new Byte[20, 30];
             Random r = new Random();
             Byte[] bytes = new Byte[data.Length];
             r.NextBytes(bytes);
             for (int i = 0; i < data.GetLength(0); i++)
            for (int j = 0; j < data.GetLength(1); j++)
               data[i, j] = bytes[i * data.GetLength(1) + j];

             Matrix<Byte> m = new Matrix<byte>(data);
             Byte[,] data2 = m.Data;

             for (int i = 0; i < data.GetLength(0); i++)
            for (int j = 0; j < data.GetLength(1); j++)
            {
               Assert.AreEqual(data[i, j], data2[i, j]);
               Assert.AreEqual(data[i, j], m[i, j]);
            }
        }
开发者ID:samuto,项目名称:UnityOpenCV,代码行数:20,代码来源:AutoTestMatrix.cs

示例7: DrawMaze

 public void DrawMaze(Byte[,] mazeToDraw)
 {
     for (UInt16 y = 0; y < mazeToDraw.GetLength(1); y++)
     {
         for (UInt16 x = 0; x < mazeToDraw.GetLength(0); x++)
         {
             // here: if cell = 255 => fill cell with a gray color
             // with layout ==> new type to handle !
             if (mazeToDraw[x, y] == 255)
             {
                 //Console.WriteLine(string.Format("[{0},{1}] = block", x,y));
                 drawABlockedCell(x, y);
             }
             else
             {
                 foreach (Direction way in Enum.GetValues(typeof(Direction)))
                 {
                     drawAWall(x, y, (Direction)mazeToDraw[x, y]);
                 }
             }
         }
     }
 }
开发者ID:InfiniteProductions,项目名称:MazeLibrary,代码行数:23,代码来源:Maze2D.cs

示例8: receive

        public string receive()
        {
            if (clientSock.Available > 0)
            {
                Byte[] dat = new Byte[clientSock.Available];
                try
                {
                    netStream.Read(dat, 0, dat.GetLength(0));
                }
                catch (Exception ex)
                {
                    eventLog.WriteEntry("Failed to receive message" + ex.Message);
                }

                return System.Text.Encoding.GetEncoding("utf-8").GetString(dat);
            }
            return "Fail";
        }
开发者ID:shintaro,项目名称:Fake_iSCT_Service,代码行数:18,代码来源:MySocketClient.cs

示例9: RC4_Process

        public Byte[] RC4_Process(Byte[] data, Byte[] key)
        {
            Byte[] s = new Byte[256];
            Byte[] k = new Byte[256];
            Byte temp;
            int i, j;

            for (i = 0; i < 256; i++)
            {
                s[i] = (Byte)i;
                k[i] = key[i % key.GetLength(0)];
            }

            j = 0;
            for (i = 0; i < 256; i++)
            {
                j = (j + s[i] + k[i]) % 256;
                temp = s[i];
                s[i] = s[j];
                s[j] = temp;
            }

            byte[] OUT = new byte[data.Length];

            i = j = 0;

            unchecked
            {
                for (int x = 0; x < data.GetLength(0); x++)
                {
                    i = (i + 1) % 256;
                    j = (j + s[i]) % 256;
                    temp = s[i];
                    s[i] = s[j];
                    s[j] = temp;
                    int t = (s[i] + s[j]) % 256;
                    OUT[x] = (byte)(data[x] ^ s[t]);
                }
            }

            return OUT;
        }
开发者ID:dipamchang,项目名称:tnetd-open,代码行数:42,代码来源:RC4.cs

示例10: DecodeMessage

 private string[] DecodeMessage(Byte[] bytes)
 {
     int arraySize = bytes.GetLength(0);
     string[] messages = new string[arraySize];
     for (int i = 0; i < arraySize; i++)
     {
         switch (bytes[i])
         {
             case (byte)Message.I2C_StartSet:
                 messages[i] = "I2C start set";
                 break;
             case (byte)Message.I2C_Busy:
                 messages[i] = "I2C is busy";
                 break;
             case (byte)Message.I2C_StartSucc:
                 messages[i] = "I2C start successful";
                 break;
             case (byte)Message.I2C_NoAck:
                 messages[i] = "I2C no ack. Stop is set";
                 break;
             case (byte)Message.I2C_Transmitter:
                 messages[i] = "I2C transmitter";
                 break;
             case (byte)Message.I2C_Receiver:
                 messages[i] = "I2C receiver";
                 break;
             case (byte)Message.I2C_CommandTrans:
                 messages[i] = "I2C command transmitted";
                 break;
             case (byte)Message.I2C_ByteRec:
                 messages[i] = "I2C byte received";
                 break;
             default:
                 messages[i] = "Unknown command";
                 break;
         }
     }
     return messages;
 }
开发者ID:vasilya93,项目名称:GDCopter2,代码行数:39,代码来源:Package.cs

示例11: getBlock

 static string getBlock(IPAddress server, int port, int blockSize)
 {
     int localport = 8009;
     string returnData = "";
     UdpClient client = new UdpClient();
     UdpClient client2 = new UdpClient(localport);
     Byte[] sendBytes = new Byte[1024];
     Byte[] receiveBytes = new Byte[1024];
     try
     {
         IPEndPoint remoteIPEndPoint = new IPEndPoint(server, localport);
         client.Connect(server.ToString(), port);
         sendBytes = Encoding.ASCII.GetBytes("NEW"+blockSize.ToString());
         client.Send(sendBytes, sendBytes.GetLength(0));
         receiveBytes = client2.Receive(ref remoteIPEndPoint);
         returnData = Encoding.ASCII.GetString(receiveBytes);
     }
     catch (Exception e)
     {
         Console.WriteLine("Error with the Server Name: {0}", e.ToString());
     }
     return returnData.TrimEnd();
 }
开发者ID:s3krit,项目名称:md5crack,代码行数:23,代码来源:Program.cs

示例12: tiWriteText_ElapsedHandler

        /// <summary>
        /// shows display text periodically
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="e"></param>
        private void tiWriteText_ElapsedHandler(Object obj, ElapsedEventArgs e)
        {
            //stop this timer
            tiWriteText.Enabled = false;
            //assign standard timer period
            tiWriteText.Interval = iScrollPeriodStandard;

            //create handle for datagram
            Byte[] btDatagram = new Byte[64];
            //byte position in datagram for content
            //Byte btBytePos = new Byte();
            //RAM adress for text
            Byte btRAMadress = new Byte();
            //create 1-dimensional byte array for futaba characters to be transferred
            btToFutaba = null;
            btToFutaba = new Byte[btTextToByteArray.GetLength(0) * btTextToByteArray.GetLength(1)];
            //fill the array from text-to-byte array argument
            //(means: convert 2-dim. array to 1-dim array)
            for (int s = 0; s < btTextToByteArray.GetLength(0); s++)
                for (int t = 0; t < btTextToByteArray.GetLength(1); t++)
                    btToFutaba[(s * btTextToByteArray.GetLength(1)) + t] = btTextToByteArray[s, t];
            //
            //reset RAM address to display start position
            btRAMadress = 0x00;
            //clear datagram
            for (int m = 0x04; m < btDatagram.GetLength(0); m++)
                btDatagram[m] = 0x00;
            //
            //as long as display is not completely filled
            while (btRAMadress < 0xC0)
            {
                //create datagram for RAM adress
                btDatagram[0x00] = 0x03;              //count of successive bytes
                btDatagram[0x01] = 0x1b;              //header (fix value)
                btDatagram[0x02] = 0x60;              //command: set RAM adress
                btDatagram[0x03] = btRAMadress;       //RAM adress
                //send command
                SendCommand(btDatagram);
                //
                //create datagram for characters
                btDatagram[0x00] = 0x3F;              //count of successive bytes
                btDatagram[0x01] = 0x1b;              //header (fix value)
                btDatagram[0x02] = 0x70;              //command: write pixel
                btDatagram[0x03] = 0x30;              //count of data bytes
                //fill in text data
                for (int n = 0x00; n < 0x30; n++)
                {
                    //if end of text has not been reached
                    if (((btRAMadress + n + iOffsVisibleText) < btToFutaba.GetLength(0)) && iOffsVisibleText != -iCharByteCount)
                        //assign next text package to datagram
                        btDatagram[n + 0x04] = btToFutaba[btRAMadress + n + iOffsVisibleText];
                    //if end of text has been reached
                    else
                    {
                        //assign long period to timer so that end of text can conviniently be recognized
                        tiWriteText.Interval = iScrollPeriodLong;
                        //reset datagram content
                        btDatagram[n + 0x04] = 0x00;
                        //reset visible text offset
                        iOffsVisibleText = -iCharByteCount;
                    }
                    //if this is the beginning of the text
                    if (iOffsVisibleText == 0x00)
                    {
                        //assign long period to timer so that beginning of text can conviniently be recognized
                        tiWriteText.Interval = iScrollPeriodLong;
                    }
                }
                //
                //send command
                SendCommand(btDatagram);
                //
                //set RAM adress for next characters
                btRAMadress = Convert.ToByte(btRAMadress + 0x30);
            }

            //increase offset    
            iOffsVisibleText += iCharByteCount;
            //start this timer again
            tiWriteText.Enabled = true;
        }
开发者ID:Datenschredder,项目名称:MediaPortal-1,代码行数:86,代码来源:FutabaMDM166A.cs

示例13: Main

        static void Main(string[] args)
        {
            //tells the system to only use available processor cycles allowing the program to run in the background
            System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Idle;

            //Greetings Screen
            Console.WriteLine("********************");
            Console.WriteLine("* Distributed MD5  *");
            Console.WriteLine("*      Cracker     *");
            Console.WriteLine("********************");
            Console.WriteLine("");
            Console.WriteLine("********************");
            Console.WriteLine("*      Client      *");
            Console.WriteLine("********************");
            Console.WriteLine("");
            Console.WriteLine("********************");
            Console.WriteLine("*     09000451     *");
            Console.WriteLine("********************");
            Console.WriteLine("");
            Console.WriteLine("--------------------");

            //connects to server
            Console.WriteLine("What is the IP of your server");
            String ServerName = Console.ReadLine();
            string hash = serverConnect(ServerName);
            Console.WriteLine("Received Hash! " + hash);
            Thread.Sleep(50);

            //starts a thread listening for multicast terminate instructions, this allows the program to continue functioning while keeping a constant listen for global instructions.
            Thread terminatorThread = new Thread(new ThreadStart(terminateThread));
            terminatorThread.Start();

            //creates udp clients for listening!
            UdpClient udpClient = new UdpClient(); //outgoing Udp
            UdpClient udpClient2 = new UdpClient(8010); //incoming port

            //section executes code while the thread is alive, this will include requesting new chunks to work through
            String resultYN = null;
            while (terminatorThread.IsAlive)
            {
                Byte[] sendBytes = new Byte[1024]; // buffer to read the data into 1 kilobyte at a time
                Byte[] recieveBytes = new Byte[1024]; // buffer to read the data into 1 kilobyte at a time
                String textinput = null;
                String returnData = "";

                //sends an initial No to the server to request a chunk, as the server is keyed to pass out new chunks to clients that don't have an answer.
                try
                {
                    IPAddress remoteAddr = Dns.GetHostEntry(ServerName).AddressList[0];  //IP address of the server entered
                    udpClient.Connect(remoteAddr.ToString(), 8009);  //address of the remotelocation
                    textinput = "n";
                    sendBytes = Encoding.ASCII.GetBytes(textinput.PadRight(1024));
                    udpClient.Send(sendBytes, sendBytes.GetLength(0));  //send the packet
                }//end of the try
                catch (Exception e)
                {
                    Console.WriteLine("Error with the Server Name: {0}", e.ToString());
                    Console.WriteLine("Did you start the Server First ?");
                }//end of the catch

                try
                {
                    //the IP Address.any allows any valid matching address for this machine to be used
                    //i.e. loopback, broadcast, IPv4, IPv6
                    IPEndPoint remoteIPEndPoint = new IPEndPoint(IPAddress.Any, 8009);  //open port 8009 on this machine
                    udpClient2.Client.ReceiveTimeout = 500; //sets timeout to prevent the programming hanging if no reply is recieved
                    recieveBytes = udpClient2.Receive(ref remoteIPEndPoint);
                    returnData = Encoding.ASCII.GetString(recieveBytes);
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Packet Timed out");
                }

                //grabs the counter value from the returned chunk packet. it only needs one value as the clients know to increment by 100000 immediately
                int counter = 0;
                try
                {
                    counter = Convert.ToInt32(returnData);
                }
                catch
                {
                    counter = 0;
                    Console.ReadLine();
                    Environment.Exit(0);
                }

                Console.WriteLine("Recieved Chunk {0} - {1}", counter, counter + 100000); //included to provide visual indication that the program is recieving chunks
                String result = checkHash(hash, counter, counter + 100000); //pass to the check hash function
                resultYN = result.Split()[0]; //the check hash function may pass back a yes result, this seperates the yes or no out for case checking

                //if the result is positive, the client sends a result packet straight away, that contains a yes terminate for the server, and the actual hash value
                if (resultYN == "y")
                {
                    try
                    {
                        IPAddress remoteAddr = Dns.GetHostEntry(ServerName).AddressList[0];  //IP address of the server entered
                        udpClient.Connect(remoteAddr.ToString(), 8009);  //address of the remotelocation
                        //read in the text from the console
                        textinput = result;
//.........这里部分代码省略.........
开发者ID:davidsivocha,项目名称:md5-llama,代码行数:101,代码来源:Client.cs

示例14: serverConnect

        //provides initial connection to the server, and checks for timeout, if no response is found
        static string serverConnect(string ServerName)
        {
            //creates updclient on this machine to recieve data
            UdpClient udpClient = new UdpClient();
            UdpClient udpClient2 = new UdpClient(8010);
            Byte[] sendBytes = new Byte[1024]; // buffer to read the data into 1 kilobyte at a time
            String textinput = null;

            //requests input of ip of server - consider switching to a multicast to join the server group

            String returnData = "";
            String hello = null;
            String hash = null;

            //sends data to the server address, in this case a Hello packet, if a hello is recieved back then the loop ends or until 4 packets have been sent
            int counter = 0;
            while (counter < 4)
            {
                try
                {
                    IPAddress remoteAddr = Dns.GetHostEntry(ServerName).AddressList[0];  //IP address of the server entered
                    udpClient.Connect(remoteAddr.ToString(), 8009);  //address of the remotelocation
                    Console.WriteLine("Testing Connection");
                    //read in the text from the console
                    textinput = "Hello";
                    sendBytes = Encoding.ASCII.GetBytes(textinput.PadRight(1024));
                    udpClient.Send(sendBytes, sendBytes.GetLength(0));  //send the packet
                }//end of the try
                catch (Exception e)
                {
                    Console.WriteLine("Error with the Server Name: {0}", e.ToString());
                    Console.WriteLine("Did you start the Server First ?");
                }//end of the catch

                try
                {
                    Byte[] recieveBytes = new Byte[1024]; // buffer to read the data into 1 kilobyte at a time
                    //the IP Address.any allows any valid matching address for this machine to be used
                    //i.e. loopback, broadcast, IPv4, IPv6
                    IPEndPoint remoteIPEndPoint = new IPEndPoint(IPAddress.Any, 8010);  //open port 8010 on this machine
                    udpClient2.Client.ReceiveTimeout = 500; //sets timeout to prevent the programming hanging if no reply is recieved
                    recieveBytes = udpClient2.Receive(ref remoteIPEndPoint);
                    returnData = Encoding.ASCII.GetString(recieveBytes);
                    hello = returnData.Split()[0];
                    hash = returnData.Split()[1];
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Packet {0} Timed out. Sending until 4!", counter + 1);
                    counter++;
                }

                if (counter == 4)
                {
                    Console.WriteLine("Unable to establish connection: program now terminating!");
                    Console.WriteLine("Press enter to close");
                }

                if (hello == "Hello")
                {
                    Console.WriteLine("Connected To Server!");
                    Console.WriteLine("");
                    counter = 4;
                }

            }
            udpClient.Close();
            udpClient2.Close();
            return hash;
        }
开发者ID:davidsivocha,项目名称:md5-llama,代码行数:71,代码来源:Client.cs

示例15: BuileNetwork

        /*
         * Function: BuileNetwork
         * Description:MATStrategy算法读取函数
         * Parameters:
         *      Byte[,] bytMatrix 从邻接矩阵生成cNet网络
         *      StyleSet pStyle 绘制样式集
         * Return Value:cNet
         */
        cNet BuileNetwork(Byte[,] bytMatrix)
		{
			cNet NewNet;
			IfPlatform NewNode;
			int intRow, intCol, i, j;

            intRow = bytMatrix.GetLength(0);
			intCol = bytMatrix.GetLength(1);
			
			NewNet = new cNet(intRow);
			for(i = 0; i < intRow; i++)
			{
				NewNode = new cNode(i);
				for(j = 0; j<intCol; j++)
				{
					if(bytMatrix[i, j] != 0)
					{
						NewNode.AddEdge(j, (double)bytMatrix[i, j]);
					}
				}
				NewNet.Network.Add(NewNode);
			}
            if (NewNet.intNumber == 0)
            {
                return null;
            }
            return NewNet;
		}
开发者ID:Dainter,项目名称:CNSP-Preussen,代码行数:36,代码来源:MATStrategy.cs


注:本文中的System.Byte.GetLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。