几何尺寸与公差论坛

 找回密码
 注册
查看: 175|回复: 0

如何标记某个类型为不可序列化?- NonSerialized

[复制链接]
发表于 2022-12-8 16:14:34 | 显示全部楼层 |阅读模式
如果需要标记某个类型为不可序列化,可以在该类型上添加[NonSerialized]特性。例如,应该把下面的代码:
namespace JZIntelli.Alg
{
    public class NotifyBase
    {
        public int MyProperty { get; set; }
    }
}
修改为:
namespace JZIntelli.Alg
{
    public class NotifyBase
    {
        [NonSerialized]
        public int MyProperty { get; set; }
    }
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-4-26 19:57 , Processed in 0.036673 second(s), 21 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表