储存已储存讯息的最佳地点 [英] Best place to store saved messages
问题描述
我当前正在创建一个控制台应用程序,它仅接受我定义的一些命令.问题是我在我创建的称为Messages的静态类上存储了很多错误和通知消息,然后像Messages.ErrorMessage ...这样调用它们.控制台.我想问的是这是否是实现这种行为的好方法,还是应该更改我保留所有这些消息的位置?
I am currently creating a console applications that only accepts some commands defined by me. The thing is I'm storing a lot of error and notification messages on a static class I created called Messages and then just calling them like Messages.ErrorMessage.... ErrorMessage is just a static string that contains w/e I want printed on the console. What I wanted to ask is if that's a good way of implementing such behavior or should I instead change where I'm keeping all of this Messages?
感谢您的帮助!
推荐答案
我想您可以使用资源文件代替静态类.
I guess for your need you can use Resource file instead of static class.
在官方网站上记录
Visual C#应用程序通常包含不是源代码的数据.此类数据称为项目资源,它可以包括二进制数据,文本文件,音频或视频文件,字符串表,图标,图像,XML文件或您的应用程序所拥有的任何其他类型的数据要求.项目资源数据以XML格式存储在.resx中可以在解决方案中打开的文件(默认名称为Resources.resx)资源管理器.
Visual C# applications often include data that is not source code. Such data is referred to as a project resource and it can include binary data, text files, audio or video files, string tables, icons, images, XML files, or any other type of data that your application requires. Project resource data is stored in XML format in the .resx file (named Resources.resx by default) which can be opened in Solution Explorer.
有关更多信息:-
http://msdn.microsoft.com/en-us/library/7k989cfy(v = VS.90).aspx
这篇关于储存已储存讯息的最佳地点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!