|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Member
Iscritto dal: Jan 2004
Città: Trapani
Messaggi: 198
|
[C#] Serializzazione struttura contenente array di bytes
Buonasera!
Avrei bisogno di serializzare una struttura in modo da poterla inviare con un socket e successivamente deserializzarla "dall'altro lato", il tutto utilizzando la classe BinaryFormatter del Framework. La struttura è la seguente: Codice:
[Serializable]
public struct pacchetto
{
public Byte[] dato;
public Byte[] checksum;
};
Ho provato anche ad implementare il costrutto ISerializable in questo modo (come anche spiegato su MSDN): Codice:
[Serializable]
public class pacchetto:ISerializable
{
public Byte[] dato;
public Byte[] checksum;
public pacchetto()
{
}
protected pacchetto(SerializationInfo info, StreamingContext context)
{
dato=(Byte[])info.GetValue("dato", typeof(Byte[]));
checksum=(Byte[])info.GetValue("check", typeof(Byte[]));
}
[SecurityPermissionAttribute(SecurityAction.Demand,SerializationFormatter=true)]
public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("dato", dato);
info.AddValue("check", checksum);
}
};
Adesso sorge spontaneo domandare: Come si fa a serializzare una struttura contenente array? Si può serializzare una struttura contenente array? Come risolvo il problema? Grazie in anticipo.
__________________
Athlon xp 2800+@3000+ bus 400Mhz, Asus a7n8x-x rev.2.0, 1GB DDR 400Mhz, ASUS V9999/TD Geforce 6800 w/ Softmod 16PS-6VS, HD Maxtor DiamondMax+9 120GB & Maxtor DiamondMax+8 40GB, SoundBlaster Audigy LS, SyncMaster 795MB, Logitech Mx510, Connessione Libero Flat 4096/256 Ultima modifica di KevoFnC : 27-02-2006 alle 00:09. |
|
|
|
|
|
#2 |
|
Member
Iscritto dal: Jan 2004
Città: Trapani
Messaggi: 198
|
Nessun' idea?
__________________
Athlon xp 2800+@3000+ bus 400Mhz, Asus a7n8x-x rev.2.0, 1GB DDR 400Mhz, ASUS V9999/TD Geforce 6800 w/ Softmod 16PS-6VS, HD Maxtor DiamondMax+9 120GB & Maxtor DiamondMax+8 40GB, SoundBlaster Audigy LS, SyncMaster 795MB, Logitech Mx510, Connessione Libero Flat 4096/256 |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 13:46.



















