1

I tried everything converting, changing but nothing seems to work I still get this error CS0029.

What am I missing, because the main method needs to satisfy everything written there, so maybe I have to change something in the Class area in the methods.

using System;

namespace CalculatorTest
{
    class Calculator
    {
        public static string WriteText(string s)
        {
            return s;
        }
        public static int WriteNumber(int n)
        {
            return n;
        }
    }

    class Program
    {
        public static void Main(string[] args)
        {
            string s = Calculator.WriteText("Hello world!");
            Console.WriteLine(s);

            string n = Calculator.WriteNumber(53 + 28);
            Console.WriteLine(n);

            Console.Read();
        }
    }
}
1
  • 1
    Not all of have all the error codes memorized. It's good to paste in the error message as well as the code. It's also to point out which line causes the error Commented Jan 19, 2020 at 3:46

1 Answer 1

3

In the class "Calculator", look at the type of the static method WriteNumber.

This method has one parameter, an "integer" 'n'. It then returns the input parameter value as an integer.

THEN, go to class "Program". You state "string n = Calculator.WriteNumber(53 + 28);". Calculator.WriteNumber returns an integer. You declare it as a string.

Change to int n = Calculator.WriteNumber(53 + 28);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.