Intenté utilizar el método List.ConvertAll y fallé. Lo que estoy tratando de hacer es convertir un List<Int32>
a byte[]
Conversión de una lista de entradas a una matriz de bytes
I Copped y fuimos esta ruta, pero necesito averiguar el método ConvertAll ...
List<Int32> integers...
internal byte[] GetBytes()
{
List<byte> bytes = new List<byte>(integers.Count * sizeof(byte));
foreach (Int32 integer in integers)
bytes.AddRange(BitConverter.GetBytes(integer));
return bytes.ToArray();
}
OoOoO Me gusta. En cuanto a ConvertAll devolver un byte [] [], ese era el problema exacto que estaba teniendo y estaba totalmente perplejo. ¡Gracias! – MQS
para aquellos que no se han movido a Visual Studio 2010, la sintaxis es ints.SelectMany (i => BitConverter.GetBytes (i)). ToArray() – zonkflut
@zonkflut: O 'enteros.SelectMany (BitConverter.GetBytes) .ToArray () ' –
SLaks