English 中文(简体)
A. 档案中的任意数据类型
原标题:Arbitrary data types in Settings file

在《公约》中,有少数缺省数据类型。 在选择“浏览”时,可以从树中增加一些。

我实际上需要把<代码>int[]储存在我的环境档案中,并且已经这样做:

[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public int[] SPLTimings
{
    get
    {
        return ((int[])(this["SPLTimings"]));
    }
    set
    {
        this["SPLTimings"] = value;
    }
}

以及方案的第一期:

int[] timings = Settings.SPLTimings ?? new int[] { 25, 100, 80, 50, 125, 50 };

之后通过<代码>Settings.Save( 予以节省。

这一点非常好,但问题很小。 如果我想利用全球倡议接口增加一个简单的数据类型,那么我的习俗增补就会删除,我必须再补充。 目前,我只有一个特别案例,因此,如果删除的话,这并不大。 另一方面,我仅能以同样的方式补充后来的一些基本环境,如插图/指示/标记:将其直接编码到环境中。 设计者档案。

必须有更好的办法这样做?

由于<代码>Settings的类别已经是部分的,因此,创建新档案,例如继续使用类别定义并包含这些模糊的类型,是否是一个更好的解决办法?

最佳回答

Settings.Designer.cs is generated automatically. So yes, you can use the fact that this class is partial, and define your own settings it another file with the same class definition. This way settings will not be overwriten.

问题回答

暂无回答




相关问题
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. ...

热门标签