Base class does not contain a constructor that takes '0' argument
刚刚在写一段直播室网站中的一段程序遇,突然遇到一个错误,如下
'TVLLKBLL.BaseClass' does not contain a constructor that takes 0 arguments,根据撑握的C#知道来剖析一下该错误的原因
俱体情况是这样的,业务逻辑中有两个类,分别是
Public class BaseClass
{
public BaseClass (string sql)
{
}
}
Public class BaseClassHelp:BaseClass
{
public BaseClassHelp (string sql)
{
}
}
其中 BaseClassHelp 继承自PagesClass
编译后会提示‘BaseClass' does not contain a constructor that takes 0 arguments
为什么呢?
我们知道类构造函数是层层向上寻找,直到基类,然后执行,然后一层层向下执行,此时我们来看BaseClassHelp类中的构造函数BaseClassHelp(string sql);如果向父类执行,此时却没有指定执行父类中的哪一个构造函数,默认情况下会去执行父类中无参数的构造函数,此时如果将父类修改成如下,即可成功编译
Public class BaseClass
{
public BaseClass ()
{
}
public BaseClass (string sql)
{
}
}
因为他有了无参构造函数
也或者在子类指定要执行父类中哪一个构造函数,子类修改成如下
Public class BaseClassHelp:BaseClass
{
public BaseClassHelp (string sql) base(sql)
{
}
}
这时子类构造函数指定执行父类中有一个参数的构造函数
Base class does not contain a constructor that takes '0' argument的更多相关文章
- C# "error CS1729: 'XXClass' does not contain a constructor that takes 0 arguments"的解决方案
出现这种错误的原因时,没有在子类的构造函数中指出仅有带参构造函数的父类的构造参数. 具体来讲就是: 当子类要重用父类的构造函数时, C# 语法通常会在子类构造函数后面调用 : base( para_t ...
- Unable to find a constructor that takes a String param or a valueOf() or fromString() method
Unable to find a constructor that takes a String param or a valueOf() or fromString() method 最近在做服务的 ...
- Base Class Doesn't Contain Parameterless Constructor?
http://stackoverflow.com/questions/7689742/base-class-doesnt-contain-parameterless-constructor #regi ...
- YII报错笔记:<pre>PHP Notice 'yii\base\ErrorException' with message 'Uninitialized string offset: 0' in /my/test/project/iot/vendor/yiisoft/yii2/base/Model.php:778
YII常见报错笔记 报错返回的代码如下: <pre>PHP Notice 'yii\base\ErrorException' with message 'Uninitialized str ...
- C# does not contain a constructor that takes no parameter
C# 中子类要重用父类的构造函数时, 一般会在子类构造函数后面调用 : base(paratype, para). 如果父类有一个參数个数为1的构造函数, 没有 0 參构造函数. 子类想要重用这个构造 ...
- A glance at C# vNext
Contents Introduction Background A list of features Primary constructor Read only auto-properties St ...
- Google JavaScript代码风格指南
Google JavaScript代码风格指南 修正版本 2.28 Aaron Whyte Bob Jervis Dan Pupius Eric Arvidsson Fritz Schneider R ...
- Google JavaScript Style Guide
转自:http://google.github.io/styleguide/javascriptguide.xml Google JavaScript Style Guide Revision 2.9 ...
- Dynamic proxy
import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; import java.lang.reflec ...
随机推荐
- Map Reduce Application(Top 10 IDs base on their value)
Top 10 IDs base on their value First , we need to set the reduce to 1. For each map task, it is not ...
- Ext JS 6学习文档-第8章-主题和响应式设计
Ext JS 6学习文档-第8章-主题和响应式设计 主题和响应式设计 本章重点在 ExtJS 应用的主题和响应式设计.主要有以下几点内容: SASS 介绍和入门 主题 响应式设计 SASS 介绍和入门 ...
- 150命令之线上查询及帮助命令 man hellp
150命令之线上查询及帮助命令 man 查询命令的帮助 man + 命令 NAME ls - list directory contents 命令+命令简单说明 SYNOPSIS ...
- HDU 1403 Longest Common Substring(后缀自动机——附讲解 or 后缀数组)
Description Given two strings, you have to tell the length of the Longest Common Substring of them. ...
- Special Offer! Super Price 999 Bourles!
Description Polycarpus is an amateur businessman. Recently he was surprised to find out that the mar ...
- c++SDK c#调用_疑难杂症
在编写过程中,会不时遇到各种问题: 1.dll明显在和exe同一目录下但调用不成功, 2.运行正常,没有报错,参数数值运行过程中也一致,但结果就是达不到预想, 都是dll没有引用完全造成的影响. 推荐 ...
- Java之I/O流(第1部分)
Java 中的I/O流: 1. 输入/输出流原理: 如下图所示:在 java 程序中,对于数据的输入/输出操作以“流”(Stream)的方式进行:J2SDK 提供了各种各样的“流”类,用来获取不同种类 ...
- 在用js拼接html时,给元素加不上事件的问题
问题描述:有时,发起ajax请求成功后,需要用js去拼接一小段html字符串,然后给某些元素添加事件时,事件总是加不上. 解决办法:在success 回调函数内,给元素添加事件绑定. 代码如下: $. ...
- 分布式系统理论-terms
Distributed programming is the art of solving the same problem that you can solve on a single comput ...
- C语言宏中"#"和"##"的用法
转自:https://www.cnblogs.com/hnrainll/archive/2012/08/15/2640558.html 在查看linux内核源码的过程中,遇到了许多宏,这里面有许多都涉 ...