C# dictionary to bytes and bytes convert to dictionary
程序员文章站
2023-04-04 14:11:33
static byte[] GetBytesFromDic(Dictionary dic) { if(dic==null || !dic.Any()) { return null; } using (MemoryStream ms = new MemoryStream( ......
static byte[] getbytesfromdic(dictionary<string,string> dic) { if(dic==null || !dic.any()) { return null; } using (memorystream ms = new memorystream()) { binaryformatter binformatter = new binaryformatter(); binformatter.serialize(ms, dic); byte[] dicbytes = ms.toarray(); return dicbytes; } } static dictionary<string,string> getdicfrombytes(byte[] dicbytes) { dictionary<string, string> dic = new dictionary<string, string>(); using (memorystream ms = new memorystream(dicbytes)) { binaryformatter binformatter = new binaryformatter(); dic= (dictionary<string,string>) binformatter.deserialize(ms); } return dic; }
memorystream ms=new memorystream(bytes);
ms.toarray()
上一篇: NCCL(Nvidia Collective multi-GPU Communication Library) Nvidia英伟达的Multi-GPU多卡通信框架NCCL 学习;PCIe 速率调研;
下一篇: SpringBoot之集成MyBatis
推荐阅读
-
C#中Dictionary类使用实例
-
浅谈C# Dictionary实现原理
-
C# dictionary to bytes and bytes convert to dictionary
-
C#中数组、ArrayList、List、Dictionary的用法与区别浅析(存取数据)
-
浅析C# Dictionary实现原理
-
C# 遍历Dictionary并修改其中的Value
-
C# Dictionary 泛型
-
c++ Convert struct to bytes
-
C#常见的几种集合 ArrayList,Hashtable,List
,Dictionary 遍历方法对比 -
C#中Dictionary泛型集合7种常见的用法