Advertisement

DirectPlay - Write() question

Started by May 14, 2004 11:55 PM
2 comments, last by strahan 20 years, 9 months ago
in C#, is it possible to send data to write other than strings/ints? (Objects such as structs, classes, etc.). If so, how do you typecast it so that it will compile? Thanks!
Just to clarify, since I haven''t gotten a response yet:

When creating a NetworkPacket to send using DirectPlay I found you can write two things to the packet: 1) string 2) int

Example:

  NetworkPacket packet = new NetworkPacket();  int x = 1;  packet.Write("Hello there");  packet.Write(x);  m_Client.Send(packet, 0, SendFlags.Sync SendFlags.NoLoopback);


Is there a way to typecast it such that you can write a struct or class object?

Example (gives compile error):

  NetworkPacket packet = new NetworkPacket();  DataStruct myData = new DataStruct();  packet.Write(myData); // <-- How can i typecast this to work???  m_Client.Send(packet, 0, SendFlags.Sync SendFlags.NoLoopback);


Thanks in advanced.

Mike

Advertisement
Try serializing it first
Yeah, I agree with him

This topic is closed to new replies.

Advertisement