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()
如对本文有疑问, 点击进行留言回复!!
使用Visual Studio2019创建C#项目(窗体应用程序、控制台应用程序、Web应用程序)
C#实现获取本地内网(局域网)和外网(公网)IP地址的方法分析
网友评论