English 中文(简体)
我如何凌驾于理论的理论
原标题:How do I override ToString() for a Dictionary

我有<条码>理论与设计;指示,外地定义与“;依赖性财产,如果我将其约束在WPF清单中,我希望它只是打印(而不是实地定义)。

是否有办法这样做?

最佳回答

我在这里可能错了,但我认为你正在寻找<条码>。 字典上的钥匙 财产;将汇回<代码>的收集。 TKey Value (就你而言,是你方言的一部分,而不是实地定义部分,而后者则会通过<代码> Property)提供。

<ListBox ItemsSource="{Binding MyDictionary.Keys}" />
问题回答

我将设立一个班级,要么执行身份证。

public class CustomDictionary : IDictionary
{
...
}

或继承 理论

public class CustomDictionary : Dictionary<string, FieldDefinition>
{
...
}

并且高于<代码> 在该类中采用的标准:

public override string ToString() 
  {
     return "My custom string";
  }

Dictionary的班级,高于String。





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

热门标签