Hi , How can I convert struct like this to array byte public struct Message { public byte id; public int value1; public int value2; public byte chkSum; } Not in this way : public void converter() { Message message; message.id = 1; message.value1 = int.MaxValue ; message.value2 = int.MaxValue ; message.chkSum = (byte)(message.id + message.value1 + message.value2) ; byte [] dataToSend = new byte [10]; dataToSend[0] = message.id ; byte [] dataToInsert = BitConverter.GetBytes (message.value1 ); Array.Copy(dataToInsert, 0, dataToSend, 1, dataToInsert.Length); dataToInsert = BitConverter.GetBytes(message.value1); Array.Copy(dataToInsert, 0, dataToSend, 5, dataToInsert.Length); dataToSend[9] = message.chkSum ; } thank you
kobi10i10
Posts
-
How to convert Struct to array -
how to turn off computerI want to turn off computer in my pograming how i can do this have a nice day/
-
how to turn off computerhi I want to turn off the computer in my pograming how i do this/ thank you.
-
PERFORMANCE PROBLEM C# vs C++i wrote the same code both in VISUALL C++ AND C#. in both cases, the OPTIMIZED SWITCH is turned on. the results: in C#, around 300 msec, in c++ less then 1 msec. what is happening here??? in general i need to process 4 megabyte each 250 msec, and it looks likt c# is not the answer... or maybe there is another optimize switch in c# i am not aware of (beside the one in the BUILD TAB). can someone please advice? is it true c# is not good for real time? THE CODE in visual studio 2005 c#: =================================================================================== using System; using System.Collections.Generic; using System.Text; using System.Diagnostics ; namespace ConsoleApplication10 { class Program { static void Main(string[] args) { byte []byte1=new byte[2097152*2]; byte[] byte2=new byte[2097152*2]; Stopwatch sw=new Stopwatch (); sw.Start (); for(int i=0;i<2097152*2;i++) { for(int y=0;y<64;y++) { if(byte1[y]==byte2[y]) //if (*(bytes1+i)==*(bytes2+i)) { } } } sw.Stop (); Console.Write ("{0}",sw.ElapsedMilliseconds ) ; Console.ReadKey (); } } } THE CODE IN VISUALL C++ 2005: =============================== #include "stdafx.h" #using #using #using using namespace System; using namespace System::Diagnostics; using namespace System::Windows::Forms; using namespace System::Drawing; using namespace System::Drawing::Drawing2D; int _tmain(int argc, _TCHAR* argv[]) { char *bytes1=new char[2097152*2]; char *bytes2=new char[2097152*2]; Stopwatch^ stopWatch; stopWatch = gcnew Stopwatch; stopWatch->Start (); //for (int u=0;u<10000;u++) for (int i=0;i<2097152*2;i++) { for (int y=0;y<64;y++) { if (bytes1[y]==bytes2[y]) //if (*(bytes1+i)==*(bytes2+i)) { } } } long ii; ii =(long)stopWatch->ElapsedMilliseconds; stopWatch->Stop (); printf("%d",ii); //ElapsedMilliseconds Ticks return 0; }
-
create form like ICQi mean a form that wouldn't be hidden by another form and the other windows will be affected by this form (the form will be showd always even if other window are open)
-
create form like ICQHi, I need to create form like ICQ/ Thank u
-
How to do sleep in microsecondHi Please help me!!!
-
open pograme in Windows formHi, I want to open program(like word) and display the appliction in my form. thank you for help. and have a good day.
-
TextBoxOk Thank u . have a nice day.
-
TextBoxuse other methods ???
-
TextBoxService Unavailable - That is what display when a click this link
-
TextBoxHi, there is why to put number in textbox with out the function convrt or (toString). have a nice day kobi.
-
Help Me Please !!! Form problmThank you very mach... and have a nice day.
-
Help Me Please !!! Form problmHi, I need to Run In My Form a Programe . the programe need to Work under my form/
-
Open Program In FormI Need To Run Program (EXE) and Display in my Form (project) have a nice day!!!
-
Form probalm!!! I nedd your help/Thank You Very Mach.
-
Form probalm!!! I nedd your help/Hi , I Need to create Form how Display on desktop and all program that will be with him . like ICQ. (When I open My Form All Item In desktop will remove left) thank you!! and have a nice day kobi
-
Insert Byte/int to TextBoxi try this way and the problam not fix but thank you anyway.
-
Insert Byte/int to TextBoxOk I try this thank you
-
Insert Byte/int to TextBoxthis is what I doing --- byte Number; convert.tostring(number); Number++; --- in thread and the CPU Process is over working