CS7036 C#没有给出与所需的形式参数相对应的参数 [英] CS7036 C# There is no argument given that corresponds to the required formal parameter of

查看:64
本文介绍了CS7036 C#没有给出与所需的形式参数相对应的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我会收到此错误?

WHy im i getting this error?

namespace CalculatorTest
{
    public class Calculator
    {
        public int operand1;
        public int operand2;
        public static string s;
        public static int n;

        public string WriteText(string s)
        {
            return s;
        }

        public string WriteNumber(int n) 
        {

            return n.ToString();
        }
        public Calculator(int operand1, int operand2) : base()
        {
            this.operand1 = operand1;
            this.operand2 = operand2;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            Calculator c = new Calculator();

        }
    }
}

推荐答案

如前所述,您为构造函数定义了两个参数(operand1,opernd2),但随后调用了任何构造函数.因此,如果您想让代码正常工作

As it is mentioned earlier You defined two parameters for constructor (operand1, operand2) but then You invoke constructor without any. So If You want to have Your code working use

Calculator c = new Calculator(5,10);

这篇关于CS7036 C#没有给出与所需的形式参数相对应的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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