C#语言功能提案 [英] C# language feature proposal

查看:77
本文介绍了C#语言功能提案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我相信接口是C#中可用的更有用的b $ b设计结构之一。但是,我觉得其中缺少一个
的东西。我建议扩展

接口以允许

构造函数的规范。不可否认,这让事情变得有点混乱,因为在界面中看到构造函数

似乎暗示界面本身可以实例化为
。但我不相信它会比使用

方法的类似情况更糟糕。通常情况下,一个类的系列将来自一个界面,该界面旨在使

具有相同的基本构造函数集。

I believe that interfaces are one of the more useful
design constructs available in C#. However, there''s one
thing that I feel is missing in them. I propose that
interfaces be expanded to allow the specification of
constructors. Admittedly, this makes things a bit
confusing in that seeing constructors in an interface
seems to imply that the interface itself can be
instantiated. But I don''t believe that it would be
significantly worse than the similar situation with
methods. Often enough, a family of classes will be
derived from an interface that are designed to have the
same basic set of constructors.

推荐答案

Merlin< jg **** @ hotmail.com>写道:
Merlin <jg****@hotmail.com> wrote:
我相信接口是C#中更有用的设计结构之一。然而,我觉得其中缺少一件事。我建议扩展
接口以允许
构造函数的规范。不可否认,这使得事情有点混乱,因为在界面中看到构造函数似乎意味着界面本身可以被实例化。但我不相信它会比使用
方法的类似情况更糟糕。通常情况下,一个类的系列将来自一个界面,该界面被设计为具有相同的基本构造函数集。
I believe that interfaces are one of the more useful
design constructs available in C#. However, there''s one
thing that I feel is missing in them. I propose that
interfaces be expanded to allow the specification of
constructors. Admittedly, this makes things a bit
confusing in that seeing constructors in an interface
seems to imply that the interface itself can be
instantiated. But I don''t believe that it would be
significantly worse than the similar situation with
methods. Often enough, a family of classes will be
derived from an interface that are designed to have the
same basic set of constructors.




And同样是静态方法。之前已经讨论过了。


-

Jon Skeet - < sk *** @ pobox.com>
< a rel =nofollowhref =http://www.pobox.com/~skeet/target =_ blank> http://www.pobox.com/~skeet/

如果回复小组,请不要给我发邮件



And likewise static methods. It''s been discussed before :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too


虽然我已经看到不允许这样做的解释,但我同意两者都会

是语言的一个很好的补充。


[]'s,

Harkos


Jon Skeet < SK *** @ pobox.com> escreveu na mensagem

新闻:MP ************************ @ news.microsoft.com ...
Although I have seen explanations for not allowing this, I agree both would
be a good addition to the language.

[]''s,
Harkos

"Jon Skeet" <sk***@pobox.com> escreveu na mensagem
news:MP************************@news.microsoft.com ...
Merlin< jg **** @ hotmail.com>写道:
Merlin <jg****@hotmail.com> wrote:
我相信接口是C#中更有用的设计结构之一。然而,我觉得其中缺少一件事。我建议扩展
接口以允许
构造函数的规范。不可否认,这使得事情有点混乱,因为在界面中看到构造函数似乎意味着界面本身可以被实例化。但我不相信它会比使用
方法的类似情况更糟糕。通常情况下,一系列类将来自一个界面,该界面被设计为具有相同的基本构造函数集。
I believe that interfaces are one of the more useful
design constructs available in C#. However, there''s one
thing that I feel is missing in them. I propose that
interfaces be expanded to allow the specification of
constructors. Admittedly, this makes things a bit
confusing in that seeing constructors in an interface
seems to imply that the interface itself can be
instantiated. But I don''t believe that it would be
significantly worse than the similar situation with
methods. Often enough, a family of classes will be
derived from an interface that are designed to have the
same basic set of constructors.



同样是静态方法。之前已经讨论过了。

-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet/
如果回复小组,请做不要给我发邮件



And likewise static methods. It''s been discussed before :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too



在接口上有构造函数有什么意义?他们不能拥有

数据,那么构建什么呢?你可能意味着抽象的构造函数,但是它不会带来任何好处,因为它们永远不能通过

接口引用访问,只能通过实现类来访问。


静态是另一个问题。


和常数。


并输入声明。


问候,


贾斯珀肯特。

" Harkos" <公顷**** @ uol.com.br>在消息中写道

新闻:OV ************** @ tk2msftngp13.phx.gbl ...
What is the point of having constructors on interfaces? They can''t have
data, so what is there to construct? You may mean abstract constructors, but
it would offer no benefit, since they could never be accessed though the
interface reference, only through the implementation class.

Statics is another issue.

And constants.

And type declarations.

Regards,

Jasper Kent.
"Harkos" <ha****@uol.com.br> wrote in message
news:OV**************@tk2msftngp13.phx.gbl...
虽然我看过解释因为不允许这样,我同意
对语言来说是一个很好的补充。

[]'s,
Harkos

" Jon Skeet < SK *** @ pobox.com> escreveu na mensagem
新闻:MP ************************ @ news.microsoft.com ...
Although I have seen explanations for not allowing this, I agree both would be a good addition to the language.

[]''s,
Harkos

"Jon Skeet" <sk***@pobox.com> escreveu na mensagem
news:MP************************@news.microsoft.com ...
Merlin< jg **** @ hotmail.com>写道:
Merlin <jg****@hotmail.com> wrote:
我相信接口是C#中更有用的设计结构之一。然而,我觉得其中缺少一件事。我建议扩展
接口以允许
构造函数的规范。不可否认,这使得事情有点混乱,因为在界面中看到构造函数似乎意味着界面本身可以被实例化。但我不相信它会比使用
方法的类似情况更糟糕。通常情况下,一系列类将来自一个界面,该界面被设计为具有相同的基本构造函数集。
I believe that interfaces are one of the more useful
design constructs available in C#. However, there''s one
thing that I feel is missing in them. I propose that
interfaces be expanded to allow the specification of
constructors. Admittedly, this makes things a bit
confusing in that seeing constructors in an interface
seems to imply that the interface itself can be
instantiated. But I don''t believe that it would be
significantly worse than the similar situation with
methods. Often enough, a family of classes will be
derived from an interface that are designed to have the
same basic set of constructors.



同样是静态方法。之前已经讨论过了。

-
Jon Skeet - < sk *** @ pobox.com>
http://www.pobox.com/~skeet/
如果回复小组,请做不要给我发邮件



And likewise static methods. It''s been discussed before :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too




这篇关于C#语言功能提案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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