"继承"来自静态类 [英] "inherit" from a static class

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

问题描述

您好我有一个由其他团队编写的静态类,它封装了一个

数据库实例。但我需要扩展它以包括其他东西。我知道C#静态类是密封的,可以继承&我不想要b $ b想要复制+粘贴代码。我怎样才能继承这些成员变量?

谢谢

Hi I have a static class written by other team which encapsulates a
database instance. but I need to extend it to incldue other things. I
know that C# static class is sealed and can;t be inherited & I don''t
want to copy + paste code. How can I inherit those member variables?
Thanks

推荐答案

HI,


你可以将课程包装在你的另一课程中


除此之外别无他法。


" ;学习" < ed ********** @ gmail.comwrote in message

news:11 ******************** *@z28g2000prd.googlegro ups.com ...


You could wrap the class in another class of yours

Other than that I see no other way.

"learning" <ed**********@gmail.comwrote in message
news:11*********************@z28g2000prd.googlegro ups.com...

您好我有一个由其他团队编写的静态类,它封装了一个

数据库实例。但我需要扩展它以包括其他东西。我知道C#静态类是密封的,可以继承&我不想要b $ b想要复制+粘贴代码。我如何继承这些成员变量?

谢谢
Hi I have a static class written by other team which encapsulates a
database instance. but I need to extend it to incldue other things. I
know that C# static class is sealed and can;t be inherited & I don''t
want to copy + paste code. How can I inherit those member variables?
Thanks



" learning" < ed ********** @ gmail.comwrote in message

news:11 ******************** *@z28g2000prd.googlegro ups.com ...
"learning" <ed**********@gmail.comwrote in message
news:11*********************@z28g2000prd.googlegro ups.com...

您好我有一个由其他团队编写的静态类,它封装了一个

数据库实例。但我需要扩展它以包括其他东西。我知道C#静态类是密封的,可以继承&我不想要b $ b想要复制+粘贴代码。我如何继承这些成员变量?

谢谢
Hi I have a static class written by other team which encapsulates a
database instance. but I need to extend it to incldue other things. I
know that C# static class is sealed and can;t be inherited & I don''t
want to copy + paste code. How can I inherit those member variables?
Thanks



打电话给他们并要求他们制作一个未密封的版本并告诉他们

你在做什么。要么他们会明白为什么他们的班级应该继承或者告诉你你在做什么你应该做其他的方式

;)


-

LTP


:)

Call them and ask them to make a version that is not sealed and tell them
what you are doing. Either they will see why their class should be
inheritable or tell you that what you are doing you should do some other way
;)

--
LTP

:)


" learning" < ed ********** @ gmail.comschrieb im Newsbeitrag

新闻:11 ******************** *@z28g2000prd.googlegro ups.com ...
"learning" <ed**********@gmail.comschrieb im Newsbeitrag
news:11*********************@z28g2000prd.googlegro ups.com...

您好我有一个由其他团队编写的静态类,它封装了一个

数据库实例。但我需要扩展它以包括其他东西。我知道C#静态类是密封的,可以继承&我不想要b $ b想要复制+粘贴代码。如何继承这些成员变量?

谢谢
Hi I have a static class written by other team which encapsulates a
database instance. but I need to extend it to incldue other things. I
know that C# static class is sealed and can;t be inherited & I don''t
want to copy + paste code. How can I inherit those member variables?
Thanks



只需编写另一个静态类并在那里添加扩展。由于静态

成员不能虚拟,所以根本不需要覆盖。


Christof

Just write another static class and add the extensions there. Since static
members can''t be virtual, there is no need to overwrite at all.

Christof


这篇关于&QUOT;继承&QUOT;来自静态类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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