110,570
社区成员
发帖
与我相关
我的任务
分享
[Serializable]
public class A
{
public List<DateTime> t1 = new List<DateTime>();
}
[Serializable]
public class A
{
public List<DateTime> t2 = new List<DateTime>();
}
System.NullReferenceException:“未将对象引用设置到对象的实例。”
[Serializable]
public class A
{
public List<DateTime> t1 = new List<DateTime>();
}
[Serializable]
public class A
{
public DateTime[] t1;
}
类型“System.Collections.Generic.List`1[System.DateTime]”的对象无法转换为类型“System.DateTime[]”。
类似的小变化,二进制序列化并没有良好的数据兼容能力,直接崩溃。[Serializable]
public class A
{
public List<DateTime> t1 = new List<DateTime>();
}
[Serializable]
public class A
{
public List<DateTime> t2 = new List<DateTime>();
}
System.NullReferenceException:“未将对象引用设置到对象的实例。”
var buff = new byte[Marshal.SizeOf(obj)];
var ptr = Marshal.UnsafeAddrOfPinnedArrayElement(buff, 0);
Marshal.StructureToPtr(obj, ptr, true);
public byte[] ToByts<T>() where T : BaseVo
{
Type _t = typeof(T);
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);
foreach (PropertyInfo item in _t.GetProperties())
{
//这里开始就不知道怎么写了如何声明和相应的属性相同的类型值
// Type _type = item.PropertyType;
//object a = Activator.CreateInstance(_type);
//bw.Write(a as IEnumerable)
}
}