.Net C#带有Hashtables的Ascending排序ArrayList [英] .Net C# Ascending sort of ArrayList with Hashtables

查看:58
本文介绍了.Net C#带有Hashtables的Ascending排序ArrayList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我遇到了问题...在.Net C#我想对包含Hashtables的ArrayList进行排序。排序键必须是Hashtable的键。我怎么能这样做?


我在这里编写了一些例子......

Hi,

I''m stuck with a problem...in .Net C# I want to sort an ArrayList containing Hashtables. The sort key must be the key of the Hashtable. How can I do this?

I''ve coded some example here...

展开 | 选择 | Wrap | 行号

推荐答案

你应该将对象强制转换回哈希表类型


欢呼。

PS:你的结构看起来很棒!
You should be typecasting the object back to a hash table type

cheers.
PS: your structure dosent look so good!


我该怎么做?只需通过(Hashtable)......或作为Hashtable?你能举个例子吗?结构有什么问题?在你必须保存列和行的情况下你会怎么做?
How can I do that? Simply by "(Hashtable)..." or "as Hashtable"? Can you give an example please? And whats wrong with the structure? How would you do it in a situation where you have to save columns and rows?


IComparer接口有两个对象进入,然后你输入到对象进行排序。 br />

至于你的结构,似乎有很多问题。

你只使用一个hastable,从不创建另一个。所以你的arraylist每次都会有相同的hastable。


在这种情况下,似乎DataTable对你更有用(定义一些colums,添加值一行)因此,每次都不是新的哈希表,而只需在DataTable中添加另一行。
IComparer interface has two objects come in, that you then type-cast to the object for sorting purposes.

As for your structure, there seems to be a lot of problems.
you are only using ONE hastable, never creating another one. So your arraylist is just going to have the same hastable in it everytime.

It rather seems that a DataTable would be more useful to you in this situation (define some colums, add values in a row) So instead of a new hashtable each time, you would just add another row to your DataTable.


这篇关于.Net C#带有Hashtables的Ascending排序ArrayList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆