在整个应用程序中使用对象 [英] Using an object throughout the entire application

查看:83
本文介绍了在整个应用程序中使用对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将XML文件反序列化为自定义类,并且需要在整个应用程序中使用该数据。

I'm deserializing an XML file into a custom class and that data needs to be used throughout my entire application.

确保数据的最佳做法是什么?可以在整个应用程序中读取和更新吗?

What are some best practices in ensuring that data can be read and updated throughout an entire application?

我的数据需要从XML文件中读取并保存到XML文件中,因此我对将数据放入应用程序设置不太感兴趣。

My data needs to be read from and saved to an XML file so I'm not too interested in putting the data in the application settings.

谢谢!

推荐答案



嗨  T Gregory,



>>确保数据有哪些最佳做法可以在整个申请中阅读和更新吗?
$


我的数据需要从XML文件中读取并保存到XML文件中,因此我对将数据放入应用程序设置不太感兴趣。


没有最好的方法,只有最好的方式。您可以参考以下想法。



您可以在任何类中声明一个全局变量,并将XML文件反序列化到此类中。  



然后,您可以在整个应用程序中阅读和更新全局xml数据。



最后,保存 全局xml数据到XML文件。



以下链接供您参考。



在C#中创建XML树(LINQ to XML)

$


最好的问候,



Yong Lu

Hi  T Gregory,

>>What are some best practices in ensuring that data can be read and updated throughout an entire application?

My data needs to be read from and saved to an XML file so I'm not too interested in putting the data in the application settings.

There is no best way, only the best way for you. You can refer the following idea.

You can declare a global variable in any class and deserializing an XML file into this class.  

Then, you can read and updated the global xml data throughout an entire application.

Finally, save the  global xml data to an XML file.

The following links for your reference.

Creating XML trees in C# (LINQ to XML)


Best Regards,

Yong Lu


这篇关于在整个应用程序中使用对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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