[Mono-dev] Unsafe struct array reading
Miguel de Icaza
miguel at novell.com
Tue Sep 8 19:09:32 EDT 2009
Hello,
Something like this:
unsafe {
byte [] copy = new byte [8192];
fixed (byte *p = (byte *) (& struct [0])){
for (int i = 0; i < 8192; i++
copy [i] = p [i];
}
filestream.Write (copy, 256);
}
> Great!
>
> Now, could you share some code about how to do it? :-P
>
> Thanks,
>
> pablo
>
> Miguel de Icaza wrote:
> > Hello,
> >
> >
> > > I'm looking for a way to read and write array of structs from a file
> > > (byte array).
> > >
> >
> > If you use the proper packing and do not care about breaking across
> > endian systems, you can always just write the entire array of structures
> > out and read them back in using unsafe pointers.
> >
> > miguel
> >
> >
> >
More information about the Mono-devel-list
mailing list