gpt4 book ai didi

c# : how to easily display a Dictionary?

转载 作者:太空宇宙 更新时间:2023-11-03 19:35:09 24 4
gpt4 key购买 nike

我有一本字典,我想以一种形式显示。最简单的方法是什么?

最好我想展示一个控件,我可以在其中使用 int 值进行排序。我尝试了 DataGridView 但没有显示任何内容,我一定是做错了什么......

代码:

mDataGridView.DataSource = mWordCount; 
/*Where mWordCount is the Dictionary<string, int> but nothing shows up. (It's a forms-app, not a web-app)*/

最佳答案

尝试 mWordCount.ToList()看看会发生什么。

解释是here :

The DataGridView class supports the standard Windows Forms data-binding model. This means the data source can be of any type that implements one of the following interfaces:

  • The IList interface, including one-dimensional arrays.
  • The IListSource interface, such as the DataTable and DataSet classes.
  • The IBindingList interface, such as the BindingList<(Of <(T>)>) class.
  • The IBindingListView interface, such as the BindingSource class.

关于c# : how to easily display a Dictionary<string, int>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2159249/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com