惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
罗磊的独立博客
月光博客
月光博客
GbyAI
GbyAI
腾讯CDC
G
Google Developers Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
U
Unit 42
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
aimingoo的专栏
aimingoo的专栏
C
Check Point Blog
Y
Y Combinator Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
I
InfoQ
雷峰网
雷峰网
B
Blog RSS Feed
美团技术团队
M
MIT News - Artificial intelligence
有赞技术团队
有赞技术团队
D
Docker

博客园 - UnseenstoneX

《打砖块创作家》隐私政策 打砖块创作家《小游戏隐私保护指引》 python 常用数据结构 Python 基本语法 地形遇到几个问题 TArray数组 UE问题分部解决 UE寻找Actor UE对话框 ShadowCaster 代码 C#读写csv文件 优化相关 unity 打开文件夹并鼠标选中某文件 Json解析 C# winform中 选择文件和保存文件 Unity与Android交互实现 一个将数据均匀分段1,2,5的随写 C# 持续序列化对象追加到文件的方法 读写文件
C#二进制序列化和反序列化
UnseenstoneX · 2018-06-06 · via 博客园 - UnseenstoneX
public class WRSerializable
{
    public static void SerializeToFile<T>(T _description, string _filePath)
    {
        using (Stream fStream = File.Create(_filePath))
        {
            BinaryFormatter binFormat = new BinaryFormatter();//创建二进制序列化器
            binFormat.Serialize(fStream, _description);
        }
    }

    public static void DeserializeFromFile<T>(ref T _description, string _filePath)
    {
        using (FileStream fileStream = File.OpenRead(_filePath))
        {
            BinaryFormatter binaryFormatter = new BinaryFormatter();
            _description = (T)binaryFormatter.Deserialize(fileStream);
        }
    }
    // public static void SerializeToFile<T>(T _description, string _filePath)
    // {
    //     FileStream fs = new FileStream(_filePath, FileMode.OpenOrCreate);
    //     BinaryFormatter bf = new BinaryFormatter();
    //     bf.Serialize(fs, _description);
    //     fs.Close();
    // }

    // public static void DeserializeFromFile<T>(ref T _description, string _filePath)
    // {
    //     FileStream fs = new FileStream(_filePath, FileMode.Open);
    //     BinaryFormatter bf = new BinaryFormatter();
    //     _description = (T)bf.Deserialize(fs);
    //     fs.Close();
    // }
}

filePath示例“mData.bin”