English 中文(简体)
保存简单数据......类似于库克群岛?
原标题:Storing Simple Data ... Similar to a Cookie?
  • 时间:2011-11-04 22:37:51
  •  标签:
  • c#

能否以窗口的形式储存简单数据? 类似于一家厨师储存价值,以说明最后被报废的工件。 这些数据是否在重载时仍然存在?

我已经有了一个数据库,如果需要,可以加以利用,但正在寻求更简单的储存解决办法。

增 编

最佳回答

我发现,最容易储存和使用像这样的环境,就是创造可序列的环境;例如:

[Serializable()]
public class Settings()
{
    public object Something { get; set; }
}

并且,如果你在申请结束时,你就可以将这一类别(即,将其作为某些地方的数据予以保存)传承。

之后,在您的申请负荷活动上:可以提取所节约的数据,你可以回过一切,因为你在结束申请之前,就使用了同样的物体。

问题回答

在此,你有多种选择。

首先,您可使用

Another, you could looking into storing the value in an AppConfig file.

Id说,上诉路线可能是最容易的。 你们都会创建档案(见这样做的链接),然后在档案中添加这一内容。

<appSettings>
    <add key="SomeValue" value="SomeString" />
<appSettings>

Then use this to access the value.

ConfigurationSettings.AppSettings["SomeValue"]

And this to set it

System.Configuration.Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
config.AppSettings.Settings.Add("SomeValue", "SomeString");
config.Save(ConfigurationSaveMode.Modified);
ConfigurationManager.RefreshSection("appSettings");

Hope this points you in the right direction.





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签