我该怎么办? [英] How do I do this please?

查看:107
本文介绍了我该怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

设计一个Windows窗体应用程序,我声明了以下内容 -



String x =;

String [] y = new String [4];



我打算将值传递给x和y,即使在退出程序或关闭计算机后也可以检索。

请指导我如何做到这一点。

谢谢。

Designing a windows form application, I declared the following -

String x = "";
String[] y = new String[4];

I intend passing values to x and y to be retrievable even after exiting the program or shutting down the computer.
Please guide me on how to do this please.
Thanks.

推荐答案

你可以用很多东西来存储东西。



*数据库(远程)

*序列化(二进制文件,本地)

*序列化(文本文件,本地)





要在数据库中存储需要知道sql的东西,你需要拥有一个数据库服务器。

有很多服务器程序,有些是:mysql,postgresql,oraclesql,...



对于序列化我只能给你一些链接:

Yaxlib。 Xml格式,人类可读

一般MS文档

Microsoft的Xml Serializer



或者您可以自己编写序列化程序。

这是一个将String []写入文件并再次读取的示例。请注意,你不能在字符串中使用'〜'。



There are plenty of things you could use to store something.

* Database (Remote)
* Serialize (Binary File, local)
* Serialize (Text File, local)


For storing something in a database you need to know sql, you need to own a database server.
There are plenty of serverprograms out there, some are: mysql, postgresql, oraclesql,...

For Serializing I can only give you some links:
Yaxlib. Xml Format, human Readable
General MS Documentation
Xml Serializer from Microsoft

Or you can write a serializer on your own.
This is a example which writes a String[] to a file and reads it again. Note you can't use '~' in the string.

string[] tok = {"test", "test", "test", "test"};
...
String toFile = "";
foreach (String s in tok) {
    toFile += s + "~";
}

File.WriteAllText("myfile.txt", toFile);





和阅读这可能是你的解决方案:





and for reading this could be your solution:

String text = File.ReadAllText("myfile.txt");
String[] arr = text.Split('~');


您需要将其保存在数据库中。
You need to save it in database.


这篇关于我该怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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