如何仅在继承中调用子类构造函数 [英] How to call subclass constructor only in inheritence

查看:71
本文介绍了如何仅在继承中调用子类构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在c#中继承是否有可能,因此我们只能在不调用基类构造函数的情况下调用子类构造函数,因为首先要调用默认的基类构造函数

Is there any possibility in inheritance in c# so that we can have subclass constructor call only without calling base class constructor as a default base class constructor calls firstly

推荐答案

子类构造函数将始终调用超类构造函数:默认的超类构造函数或(可能已参数化的)超类构造函数,您可以在您选择时选择声明您的子类构造函数.

A subclass constructor will always call a superclass constructor: either the default superclass constructor or a (maybe parametrized) superclass constructor, which can be chosen by you, when you declare your subclass constructor.

这篇关于如何仅在继承中调用子类构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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