C#继承问题 - 不包含带有0个参数的构造函数 [英] C# Inheritance Issue - Does not contain a constructor that takes 0 arguments

查看:1111
本文介绍了C#继承问题 - 不包含带有0个参数的构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了一些其他相关的文章,但我不相信我有同样的问题,他们做。我相信我正在为我继承的类做我的构造函数,但它仍然不会工作,甚至不会认识到我有一个构造函数在那里似乎。

I've read through some of the other posts that are related but I don't believe I have the same problem that they do. I believe I'm doing my constructor for my inherited class properly, however it still won't work - and won't even recognize that I have a constructor there it seems.

class BlockedNumber : PhoneNumber
{
    public BlockedNumber(string a, string m, string l)
        : base(a, m, l) { }
}

给我标题中的错误:


DTS.PhoneNumber不包含接受0个参数的构造函数。

我不知道为什么它不能正确识别我的构造函数。错误(VS12中的蓝色下划线)第一次使用 BlockedNumber 之后

I don't know why it isn't recognizing my constructor properly. The error (blue underline in VS12) is on the first use of BlockedNumber right after class.

推荐答案

利用你所拥有的和从VS2010生成类

Taking what you have and Generating a class from VS2010

internal class PhoneNumber
    {
        private string a;
        private string m;
        private string l;

        public PhoneNumber(string a, string m, string l)
        {
            // TODO: Complete member initialization
            this.a = a;
            this.m = m;
            this.l = l;
        }
    }

class BlockedNumber : PhoneNumber
{
    public BlockedNumber(string a, string m, string l)
        : base(a, m, l) { }
}

编译正好很好,就像Yuriy说这个问题必须在别的地方。

这篇关于C#继承问题 - 不包含带有0个参数的构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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