Click here to Skip to main content
15,922,574 members
Home / Discussions / C#
   

C#

 
GeneralRe: PreProcessMessage Pin
Joshua Nussbaum24-May-02 6:27
Joshua Nussbaum24-May-02 6:27 
GeneralCrystal Reports Not Working Pin
Gavin_Mannion24-May-02 3:55
Gavin_Mannion24-May-02 3:55 
GeneralMDIChild Activated() event not firing...... Pin
Pranoti24-May-02 1:45
Pranoti24-May-02 1:45 
GeneralRe: MDIChild Activated() event not firing...... Pin
Rocky Moore24-May-02 19:17
Rocky Moore24-May-02 19:17 
GeneralSockets/Objects/Serializable Pin
Paddy24-May-02 1:30
Paddy24-May-02 1:30 
GeneralRe: Sockets/Objects/Serializable Pin
James T. Johnson24-May-02 7:54
James T. Johnson24-May-02 7:54 
GeneralRe: Sockets/Objects/Serializable Pin
tmagoo24-May-02 19:39
tmagoo24-May-02 19:39 
GeneralRe: Sockets/Objects/Serializable Pin
James T. Johnson25-May-02 4:17
James T. Johnson25-May-02 4:17 
That's pretty what the binary serializer does except it has type safety built in.

Using the methods I created you would do something like this.

private byte[] GetMyClassBytes(MyClass mc)
{
  return GetObjectBytes(mc);
}
 
private MyClass GetMyClassFromBytes(byte[] bytes)
{
  return (MyClass) GetObjectFromBytes(bytes);
}
To go from object to a specifc class you just need to cast or use the as keyword if you don't want to throw an exception if it is the wrong type (return GetObjectFromBytes(bytes) as MyClass returns null if the object isn't of type MyClass).

James

Simplicity Rules!
GeneralRe: Sockets/Objects/Serializable Pin
Paddy25-May-02 4:39
Paddy25-May-02 4:39 
GeneralRe: Sockets/Objects/Serializable Pin
tmagoo26-May-02 3:35
tmagoo26-May-02 3:35 
GeneralRe: Sockets/Objects/Serializable Pin
Paddy27-May-02 2:37
Paddy27-May-02 2:37 
GeneralRe: Sockets/Objects/Serializable Pin
tmagoo29-May-02 10:59
tmagoo29-May-02 10:59 
GeneralRe: Sockets/Objects/Serializable Pin
James T. Johnson29-May-02 18:02
James T. Johnson29-May-02 18:02 
GeneralRe: Sockets/Objects/Serializable Pin
tmagoo30-May-02 3:14
tmagoo30-May-02 3:14 
GeneralPlatform Interop - Structures and Arrays Pin
Mikko Puonti24-May-02 0:09
Mikko Puonti24-May-02 0:09 
GeneralXmlDocument with DTD driving me insane! Pin
Daniel Turini23-May-02 10:21
Daniel Turini23-May-02 10:21 
QuestionWindows services???? Pin
Rickard Andersson2023-May-02 4:37
Rickard Andersson2023-May-02 4:37 
AnswerRe: Windows services???? Pin
Nish Nishant23-May-02 17:06
sitebuilderNish Nishant23-May-02 17:06 
GeneralRe: Windows services???? Pin
Rickard Andersson2023-May-02 20:48
Rickard Andersson2023-May-02 20:48 
GeneralRe: Windows services???? Pin
Nish Nishant23-May-02 20:52
sitebuilderNish Nishant23-May-02 20:52 
GeneralRe: Windows services???? Pin
Rickard Andersson2023-May-02 21:20
Rickard Andersson2023-May-02 21:20 
GeneralRe: Windows services???? Pin
Nish Nishant23-May-02 21:20
sitebuilderNish Nishant23-May-02 21:20 
GeneralRe: Windows services???? Pin
Rickard Andersson2023-May-02 22:17
Rickard Andersson2023-May-02 22:17 
GeneralRe: Windows services???? Pin
Nish Nishant23-May-02 22:17
sitebuilderNish Nishant23-May-02 22:17 
GeneralRe: Windows services???? Pin
A.A.29-May-02 17:20
A.A.29-May-02 17:20 

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.