在序列化期間,我們可以使用內存流或文件流。內存流和文件流的區別
這兩者之間的基本區別是什麼?記憶流是什麼意思?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
namespace Serilization
{
class Program
{
static void Main(string[] args)
{
MemoryStream aStream = new MemoryStream();
BinaryFormatter aBinaryFormat = new BinaryFormatter();
aBinaryFormat.Serialize(aStream, person);
aStream.Close();
}
}
}
由於對象已經在內存中,爲什麼我們要分配一個內存流進行serilization? – Raghav55
由於內存流將對象作爲一系列字節進行操作,而不是其邏輯程序「含義」。 – Tudor
@tudor:因爲我是.net的新手,你能解釋一下嗎? – Raghav55