扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:谢启东编译 来源:天极开发 2007年11月14日
关键字:
using namespace System; using namespace System::IO; using namespace System::Runtime::Serialization::Formatters::Binary; int main() { Console::WriteLine("PointCount: {0}", Point::PointCount); Point^ p1 = gcnew Point(15, 10); Point^ p2 = gcnew Point(-2, 12); array<Point^>^ p3 = {gcnew Point(18, -5), gcnew Point(25, 19)}; Console::WriteLine("PointCount: {0}", Point::PointCount); BinaryFormatter^ formatter = gcnew BinaryFormatter; Stream^ file = File::Open("Point.ser", FileMode::Create); formatter->Serialize(file, p1); formatter->Serialize(file, p2); formatter->Serialize(file, p3); file->Close(); file = File::Open("Point.ser", FileMode::Open); Point^ p4 = static_cast<Point^>(formatter->Deserialize(file)); Console::WriteLine("PointCount: {0}", Point::PointCount); Point^ p5 = static_cast<Point^>(formatter->Deserialize(file)); Console::WriteLine("PointCount: {0}", Point::PointCount); array<Point^>^ p6 = static_cast<array<Point^>^>(formatter->Deserialize(file)); Console::WriteLine("PointCount: {0}", Point::PointCount); file->Close(); Console::WriteLine("p1: {0}, p4: {1}", p1, p4); Console::WriteLine("p2: {0}, p5: {1}", p2, p5); Console::WriteLine("p3[0]: {0}, p6[0]: {1}", p3[0], p6[0]); Console::WriteLine("p3[1]: {0}, p6[1]: {1}", p3[1], p6[1]); } |
PointCount: 0 PointCount: 4 PointCount: 5 PointCount: 6 PointCount: 8 p1: (15,10), p4: (15,10) p2: (-2,12), p5: (-2,12) p3[0]: (18,-5), p6[0]: (18,-5) p3[1]: (25,19), p6[1]: (25,19) |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者