泛型,集合,可持久都相似..? [英] Generic,Collection,Hastable are similar..?

查看:74
本文介绍了泛型,集合,可持久都相似..?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,

泛型,集合,哈希表之间的区别是什么,并指导我使用它们.我也不想知道还有其他与C#中类似的概念.

问候:
Ramesh ch Tulal

Hello there

What the differences between Generic,Collection,Hashtable And guide me whn to use them.I also wnt to know is there any other concept similar to these in C#.

Regards:
Ramesh ch Tulal

推荐答案

A HashTableCollection类型的Generic类型.您正在寻找不同商品之间的区别.

如果要收集固有类型(例如整数或字符串)的唯一值的集合,请使用HashTable.您可以使用复杂的对象,但这意味着您必须以某种方式扩展HashTable类以支持该类型,或者必须在集合对象类中使用ToString()覆盖.考虑到麻烦以及有关哈希表的性能问题,如果要使用复杂的对象,最好使用简单的List.当然,您仍然需要编写AddUnique代码,但这很容易做到.
A HashTable is a type of Collection of Generic types. You''re looking for differences between unlike items.

A HashTable is used when you want a collection of unique values of an intrinsic type, such as integers or strings. You can use complex objects, but that means you have to somehow extends the HashTable class to support the type, or you must have a ToString() override in your collection object class. Given the hassles, and the performance issues regarding hashtables, you''d be better of with a simpl List if you want to use complex objects. Of course, you would still be on the hook for writing the AddUnique code, but that''s pretty easy to do.


1)集合-
一组整数,字符串和对象等在一起...
您可以为此添加不同的数据类型,您可以将其称为非通用集合
您需要处理类型转换的开销.


2)通用-收集某些数据类型.
我们需要定义此Collection可以容纳的数据类型.
这将是类型安全的,并且可以避免非
的运行时类型转换问题 通用计数器零件.

3)HashTable-具有定义类型的KEY和VALUE的某些类型的集合.
每个定义类型的键都将映射一个定义的值.

http://download.oracle.com/javase/6/docs/api/java/util/Hashtable.html [ ^ ]
1) Collection -
A group of integers, strings and objects,etc together...
You can add different data types to this, u can call it non-generic collection
you need to go through overhead of type conversion.


2) Generic - Collection of certain data types.
We need to define the datatype this Collection would hold.
It would be type safe and avoid run time type conversion problems with non-
generic counter part.

3) HashTable - Collection of certain types with KEY and VALUE of defined types.
Each Key of defined type would map a defined Value.

http://download.oracle.com/javase/6/docs/api/java/util/Hashtable.html[^]


这篇关于泛型,集合,可持久都相似..?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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