Ошибка преобразования значения «AQID» в тип «System.Collections.Generic.IEnumerable`1[System. Байт]'
Код: Выделить всё
public class ByteArrayTest
{
public string SomeString { get; set; }
public IEnumerable ByteArray { get; set; }
}
using Newtonsoft.Json;
[TestClass]
public class UnitTest10
{
[TestMethod]
public void TestTheByteArraySerialization()
{
var test = new ByteArrayTest { ByteArray = new byte[] { 1, 2, 3 }, SomeString = "testing" };
var serializedData = JsonConvert.SerializeObject(test);
//This line belows fails with an error of can't convert to IEnumerable
var myByeArrayClass = JsonConvert.DeserializeObject(serializedData);
Assert.AreEqual(test.ByteArray, myByeArrayClass.ByteArray);
}
}
Подробнее здесь: https://stackoverflow.com/questions/174 ... eserialize