将数据保存在对象vb.net中 [英] Save data in objects vb.net

查看:156
本文介绍了将数据保存在对象vb.net中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个WPf应用程序,该应用程序可以通过无线电频率与仪器进行通信.我有一个DLL库.我的导师告诉我,应该创建对象,以便可以存储乐器中的数据.我想知道是否有人可以告诉我如何在VB.net中创建对象来存储数据然后使用它们.
感谢

I am developing an WPf application that can communicate with instruments by radio frecuencie. I have one DLL library. My tutor told me that I should create objects where I can store the data from the instruments. I wonder if someone can give me an idea of ​​how I can create objects in VB.net to store data and then can use them.
thanks

推荐答案

您的问题没有任何意义,因为如果您完全使用vb.net,那么您正在创建对象.如果不使用至少一个对象,则无法创建任何vb.net应用程序.
其他一切都取决于仪器和您需要收集的数据:类只是您使用的模型的表示,对象是类的实例.
Your question makes no sense, since if you use vb.net at all, you are creating objects. You can not make any vb.net application without using at least one object.
Everything else depends on instrument and the data you need to collect: a class is just a representation of the model you are using, an object is an instance of a class.


我同意Solution 1,但如果您正确地提出问题,这将是有道理的.您可以拥有一些数据类,这些数据类允许您基于流(文件,网络流以及更多)从某些持久性存储中进行保存和恢复.

最好的方法是使用数据合同.请参阅: http://msdn.microsoft.com/en-us/library/ms733127.aspx [ ^ ].

它将允许您创建任意的对象图,进行保存,然后在相同或不同的过程中完全恢复之前的状态.对象图甚至可以包含循环(循环引用).而且,这种方法非常简单(您只需向班级和成员添加一些.NET 属性即可参加合同),并且非常易于使用.我在过去的回答中主张采用这种方法:
如何在我的表单应用程序? [ ^ ],
创建属性文件... [
I agree with Solution 1, but if you formulate the problem correctly, it would make sense. You can have data classes which allows you to get saved and restored to/from some persistent storage based on a stream: a file, network stream, and a lot more.

The best way to do it is by using Data Contracts. Please see: http://msdn.microsoft.com/en-us/library/ms733127.aspx[^].

It will allow you to create any arbitrary object graph, save it and later restore it exactly how it was before, in the same or different process. The object graph can even contain loops (circular references). Also, this approach is very unobtrusive (you only add some .NET attribiutes to classes and members to participate in the contract) and is very easy to use. I advocate this approach in my past answers:
How can I utilize XML File streamwriter and reader in my form application?[^],
Creating property files...[^].

—SA


这篇关于将数据保存在对象vb.net中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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