输入和输出流可以实现吗? [英] Can input and output stream achieve this?

查看:64
本文介绍了输入和输出流可以实现吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我目前正在使用Visual Studio 2008从事一个大学项目. C#,Windows窗体应用程序.

在程序的第一部分,我需要生成大量的double数组[144],就像其中的1万个数组一样.这非常耗时,每次启动程序时都需要重复执行该步骤.

因此,我正在考虑生成大量的双精度数组并将其存储到一些外部数据中.然后,每当我启动程序时,我的程序就会将这些大量的双精度数组加载到程序存储器中.

所以,我可以通过使用I/O流来实现这一点吗?

Hi all, I''m currently working on a college project using Visual studio 2008< C#,windows form application.

In the very 1st part of my program, i need to generate a large number of double array [144], like 10 thousand of them. It is very time-consuming and i need to repeat the step everytime i start my program.

So, i''m thinkin of generating these large number of double array and store it into some external data. Then everytime i start my program, my program will load these large number of double array in the program memory.

So, can i acchieve this by using I/O stream? How?

推荐答案

简单的方法是序列化.您可以使用二进制或XML.

我认为XML一个适合您.在MSDN上检查XmlSerializer.
The simples way will be serialization. You can use binary or XML one.

I think that XML one will be OK for you. Check XmlSerializer on MSDN.


您最好对Double使用BinaryWriter读/写重载函数.

http://msdn.microsoft.com/en-us/library/ez8wcba9.aspx [ ^ ]

对于查找,只需获取索引并将其乘以双倍的大小即可得到正确的文件位置.
You could best use the BinaryWriter Read/Write overload functions for Double to do that.

http://msdn.microsoft.com/en-us/library/ez8wcba9.aspx[^]

For seeking you simply take the index and multiply it with the size of a double to get at the correct file position.
BinaryWriterObject.Seek(index * sizeof(double), SeekOrigin.Begin);



祝你好运!



Good luck!


这篇关于输入和输出流可以实现吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆