通用类? [英] Generic Class ??

查看:74
本文介绍了通用类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


有人可以帮我指出一些情况,我们会这样或者说b $ b必须使用Generic Class?

我可以预见Generic Method功能强大,但我找不到单一的

情况我需要Generic Class,因为有这么多其他

选项。


-

干杯,

RL

解决方案

Egghead写道:


大家好,


可以有人慷慨地指出我要处理的某些情况,或者说b $ b必须使用Generic Class?

我可以预见Generic Method功能强大,但我找不到单一的

情况我需要Generic Class,因为有这么多其他

选项。



没有你_need_使用泛型的情况,但它非常好

在某些情况下很方便,并提供更简单,更快速和更稳定的代码。


列表< Tclass例如使ArrayList过时,因为它确实是
$ b $同样的事情,只有更好。它的类型安全,易于使用,性能更好。


-

G?跑Andersson

_____
http://www.guffa.com


您好


我们为所有Business Objects使用Generic基类,这个基类

包含我们所有的数据访问,常见的业务逻辑,对象缓存等,

,同时保持类型安全。我们现在处于派生对象的阶段

字面上包含一堆属性和非常具体的业务逻辑。


同样,不是必须的,但是我们发现它非常强大,有弹性,而且很快就可以编码。


干杯


汤姆

" Egghead"写道:


大家好,


有人可以指出我会遇到的一些情况或

必须使用Generic Class?

我可以预见Generic Method功能强大,但我找不到单一的

情况我需要Generic Class,因为有这么多其他

选项。


-

欢呼,

RL


谢谢,但你的例子是通用编程,我理解为什么。它

就像模板链表。我绝对是那样的。但是,

级?

我无法用它做任何事情:''(


-

欢呼,

RL

" G?ran Andersson"< gu *** @ guffa.comwrote in message

新闻:O6 ************** @ TK2MSFTNGP03.phx.gbl ...


Egghead写道:


>大家好,

有人能够指出我们将要或者必须使用通用类的某些情况吗?
我可以预见Generic Method功能强大,但我找不到一个单一的情况,我需要Generic Class,因为有很多
其他选项。



没有你需要使用泛型的情况,但在某些情况下它非常便宜
,并提供更简单,更快速和更稳定的代码。


列表< Tclass例如使ArrayList过时,因为它与

相同,只有b etter。它的类型安全,更易于使用,并且更好地执行



-

G?ran Andersson

_____
http://www.guffa.com



Hi all,

Can someone kindly enough point me to some situations that we shall or
"must" use Generic Class?
I can foresee the Generic Method is powerful, but I can not find a single
situation that I will need the Generic Class, given there are so many other
options.

--
cheers,
RL

解决方案

Egghead wrote:

Hi all,

Can someone kindly enough point me to some situations that we shall or
"must" use Generic Class?
I can foresee the Generic Method is powerful, but I can not find a single
situation that I will need the Generic Class, given there are so many other
options.

There is no situation where you _need_ to use generics, but it''s very
handy in some situations, and gives simpler, faster and more stable code.

The List<Tclass for example makes ArrayList obsolete, as it does the
same thing, only better. It''s type safe, easier to use, and performs better.

--
G?ran Andersson
_____
http://www.guffa.com


Hi

We use a Generic base class for all our Business Objects, this base class
contains all our Data Access, common business logic, object caching, etc,
whilst remaining type safe. We''re at the stage now where the derived objects
literally contain a bunch of properties and very specific business logic.

Again, not a must, but we''re finding it extremely powerful, resilient and
very quick to code against.

Cheers

Tom
"Egghead" wrote:

Hi all,

Can someone kindly enough point me to some situations that we shall or
"must" use Generic Class?
I can foresee the Generic Method is powerful, but I can not find a single
situation that I will need the Generic Class, given there are so many other
options.

--
cheers,
RL


Thanks, but your example is Generic programming which I understand why. It
is like template linked list. I am absolutely like that. However, the
Class??
I can not do anything with it :''(

--
cheers,
RL
"G?ran Andersson" <gu***@guffa.comwrote in message
news:O6**************@TK2MSFTNGP03.phx.gbl...

Egghead wrote:

>Hi all,

Can someone kindly enough point me to some situations that we shall or
"must" use Generic Class?
I can foresee the Generic Method is powerful, but I can not find a single
situation that I will need the Generic Class, given there are so many
other options.


There is no situation where you _need_ to use generics, but it''s very
handy in some situations, and gives simpler, faster and more stable code.

The List<Tclass for example makes ArrayList obsolete, as it does the
same thing, only better. It''s type safe, easier to use, and performs
better.

--
G?ran Andersson
_____
http://www.guffa.com



这篇关于通用类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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