Click here to Skip to main content
15,919,749 members
Home / Discussions / C#
   

C#

 
GeneralRe: Setting Form's size problems Pin
Acidis31-May-03 11:47
Acidis31-May-03 11:47 
GeneralRe: Setting Form's size problems Pin
James T. Johnson31-May-03 18:06
James T. Johnson31-May-03 18:06 
GeneralRe: Setting Form's size problems Pin
Acidis31-May-03 19:36
Acidis31-May-03 19:36 
GeneralRe: Setting Form's size problems Pin
James T. Johnson31-May-03 19:59
James T. Johnson31-May-03 19:59 
GeneralMenue by Marc Clifton Pin
Frenchi31-May-03 9:46
Frenchi31-May-03 9:46 
GeneralRe: Menue by Marc Clifton Pin
Marc Clifton31-May-03 15:33
mvaMarc Clifton31-May-03 15:33 
GeneralRe: Menue by Marc Clifton Pin
Frenchi1-Jun-03 5:12
Frenchi1-Jun-03 5:12 
Questionto byte[] conversion? Pin
stonee7431-May-03 3:38
stonee7431-May-03 3:38 
Hello there,

I'm getting crazy.
Maybe somebody of you guys have some good ideas how to solve this.
Imagine, There is an existing API in C++.
The main idea of this interface is to exchange byte arrays with a server.
In the example below you see the principle.
I create e.g. a object myCommand from the 'Command' struct which again consists of enumns and structs.
The idea is to to send these binary data of the enumns and structs down to the server.

In c++ i create this object and send it like that:

Socket.send(&myCommand, sizeof(blabla));

As you see i just need to give a pointer to my data.


I decided to translate this interface to C#, since writing a wrapper would be about the same work(?!).
Anyway, the biggest problem i have is:
How can i create a byte[] from myCommand object, containg all the numerical enum and struct data to be able to send it to the server???
Sockets in C# are only accepting byte[] as parameter, but how to convert 'myCommand Object' to byte?
There are dozens of examples how to decode strings to byte arrays but I did not found any material abot converting my stuff!
One thing i thought about is to use serializing, but since the future app should run on a PocketPC on the Compact Framwork,
this is not possible since the .NET CF is not supporting serializing......

Any help, ideas tips and tricks would be greatly appreciated!

regards,
stonee



//example, principle of API<br />
<br />
	enum DataType<br />
	{<br />
		Command = 0,<br />
		Error = 1,<br />
		Result = 2,<br />
	};<br />
<br />
	enum Command<br />
	{<br />
		Exit = 0,                            <br />
		GetValueA = 1,                           <br />
		GetValueB = 2,                          <br />
		GetValueC = 3,               <br />
		GetValueD = 4,   <br />
	};<br />
<br />
<br />
	struct Header<br />
	{<br />
		public long         lPacketSize;<br />
		public DataType     type;<br />
	}<br />
<br />
<br />
	struct Command<br />
	{<br />
		public Header    packetHeader;<br />
		public Command   command;<br />
	}<br />
<br />
<br />
<br />
<br />
	Command myCommand = new Command();<br />
<br />
	Socket.send(&myCommand, sizeof(blabla));

AnswerRe: to byte[] conversion? Pin
Eric Gunnerson (msft)31-May-03 16:34
Eric Gunnerson (msft)31-May-03 16:34 
GeneralRe: to byte[] conversion? Pin
stonee7431-May-03 17:01
stonee7431-May-03 17:01 
GeneralRe: to byte[] conversion? Pin
Eric Gunnerson (msft)1-Jun-03 7:05
Eric Gunnerson (msft)1-Jun-03 7:05 
GeneralRe: to byte[] conversion? Pin
stonee741-Jun-03 8:04
stonee741-Jun-03 8:04 
GeneralRe: to byte[] conversion? Pin
Eric Gunnerson (msft)3-Jun-03 9:43
Eric Gunnerson (msft)3-Jun-03 9:43 
GeneralResource Troubles (MissingManifestResourceException) Pin
gek_at31-May-03 2:02
gek_at31-May-03 2:02 
GeneralRe: Resource Troubles (MissingManifestResourceException) Pin
gek_at31-May-03 2:18
gek_at31-May-03 2:18 
GeneralRe: Resource Troubles (MissingManifestResourceException) Pin
David Stone31-May-03 6:23
sitebuilderDavid Stone31-May-03 6:23 
QuestionIf C# is Microsoft's answer to SUN's Java, then is C# Platform independent? Pin
Link260030-May-03 23:56
Link260030-May-03 23:56 
AnswerRe: If C# is Microsoft's answer to SUN's Java, then is C# Platform independent? Pin
Kannan Kalyanaraman31-May-03 0:56
Kannan Kalyanaraman31-May-03 0:56 
AnswerRe: If C# is Microsoft's answer to SUN's Java, then is C# Platform independent? Pin
David Stone31-May-03 6:15
sitebuilderDavid Stone31-May-03 6:15 
AnswerRe: If C# is Microsoft's answer to SUN's Java, then is C# Platform independent? Pin
FruitBatInShades31-May-03 23:57
FruitBatInShades31-May-03 23:57 
GeneralRe: If C# is Microsoft's answer to SUN's Java, then is C# Platform independent? Pin
Link26001-Jun-03 6:09
Link26001-Jun-03 6:09 
QuestionHow do I draw graphics on the StatusBar ? Pin
JeffSayHi30-May-03 21:27
JeffSayHi30-May-03 21:27 
AnswerRe: How do I draw graphics on the StatusBar ? Pin
James T. Johnson31-May-03 18:16
James T. Johnson31-May-03 18:16 
AnswerRe: How do I draw graphics on the StatusBar ? Pin
Manster2-Jun-03 9:45
Manster2-Jun-03 9:45 
GeneralHello Pin
Hussein Zahran30-May-03 8:04
Hussein Zahran30-May-03 8:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.