随笔分类 - C#
C#语言在各平台的使用
摘要:网上看到别人在写这样一个方法,就尝试能够在Unity中使用该方法。记住要使用的程序包:using System.IO;using System.Runtime.Serialization.Formatters.Binary;public object DeepCopy(object src){MemoryStream ms = new MemoryStream();BinaryFormatter bf = new BinaryFormatter();bf.Serialize(ms, src);ms.Seek(0, SeekOrigin.Begin);object dst = bf.Deseri
阅读全文
摘要:基于BZip2的压缩方式(ICSharpCode.SharpZipLib)压缩和解压代码举例:MemoryStream ms = new MemoryStream(); BZip2OutputStream zlib = new BZip2OutputStream(ms); byte[] src = Encoding.UTF8.GetBytes("#¥%……%……&@"); zlib.Write(src, 0, src.Length); zlib.Close(); byte[] press = ms.ToArray(); Debug.Log(Convert.ToBas
阅读全文
摘要:因为Unity中的.net支持是有限制的,所以C#自带的GZip的压缩方法不能够使用。 可以到下面网址去下载一个专门的dll来处理数据的GZip压缩:http://www.icsharpcode.net/OpenSource/SharpZipLib/Download.aspx将下载的dll文件引入到工程中。引入头部:using ICSharpCode.SharpZipLib;using ICSharpCode.SharpZipLib.GZip;以下代码实现了压缩和解压的方法: MemoryStream ms = new MemoryStream(); GZipOutput...
阅读全文
摘要:MessagePack提供了很多中语言的实现方式。以C#语言为例:(代码来自MessagePack的网站)Simple Packer/UnpackerBoxingPacker Exampleusing MsgPack; namespace Test { public class TestApp { public static void Main () { BoxingPacker packer = new BoxingPacker (); object[] obj = new object[] { new object[] {1, 2, 3, 4}, ...
阅读全文
浙公网安备 33010602011771号