English 中文(简体)
怎样才能控制干ash(-)?
原标题:How can i get enum to contain a dash (-)?
最佳回答

你们可以 t。 完全停止。 然而,有一些工作。 例如,你可以使用<代码>DescriptionAttribute:

public enum PackageMedium : int {
    NTP,
    DAT,
    Exabyte,
    [Description("CD-ROM")]
    CDROM,
    DLT,
    D1,
    DVD,
    BD,
    LTO,
    LTO2,
    LTO4
}

不幸的是,这意味着,在绘制价值观时,你要做更多的工作。 而另一方面,它汇编成册。

如果你不喜欢这样的话,就再做工作,比如说,字典:

var dict = Enum.GetValues(typeof(PackageMedium))
               .Cast<PackageMedium>()
               .Select(v => Tuple.Create(v == PackageMedium.CDROM ? "CD-ROM" : v.ToString(), v))
               .ToDictionary(t => t.Item1, t => t.Item2);

var myEnumVal = dict["CD-ROM"];
问题回答

我知道,这是很晚的,但这可能是有用的。

另一项工作是利用XmlEnumAttribute:

public enum PackageMedium : int {
NTP,
DAT,
Exabyte,
[XmlEnumAttribute("CD-ROM")]
CDROM,
DLT,
D1,
DVD,
BD,
LTO,
LTO2,
LTO4
}

它用于鉴定带有Xsd的xml。 不需要额外的法典。

A. 导 言 C#识别器首先必须强调,在统一编码类别Lu、Ll、Lt、Lm、L、或Nl中,或其中一人逃脱。 所有其他特性必须来自统法协会的L、Ll、Lt、Lm、L、L、Nl、Mn、Mc、Nd、Pc或Cf等类,或其中一人的越狱。

Hyphen-minus is of category Pd.

如果C#的确允许,如果你需要符合《公约》的规定,那么你仍然可以不使用《公约》的公开标识,因为《公约》也不符合其规则。

这也是你打算如何区分<代码>CD-ROM,意思是<代码>enum从CD-ROM中的特定项目,意思是将<代码>-<>>>>->>>> /code>作为左手操作器和ROM作为右手操作体使用<代码>>-<<<>>>>>>>>>>>>。

如果这种可能性清单难以编码,那么我就删除了Hphen-minus,并将CDROM作为标签。 如果它没有硬编码一,则使用字典,因为它面对更多的情况,即有些情况可能没有识别特征。





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

热门标签