Csharp/C Sharp by API/System.IO/Serializable — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
| |
Текущая версия на 12:12, 26 мая 2010
mark Serializable
using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
class MainClass
{
[STAThread]
static void Main(string[] args)
{
Point p1 = new Point();
p1.xpoint = 1;
p1.ypoint = 2;
Stream stream = File.Open("point.bin", FileMode.Create);
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Serialize(stream, p1);
stream.Close();
Stream openStream = File.Open("point.bin", FileMode.Open);
Point desierializedPoint = new Point();
desierializedPoint = (Point)bformatter.Deserialize(openStream);
}
}
[Serializable()]
class Point
{
public int xpoint;
public int ypoint;
}