Click here to Skip to main content
15,891,833 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I'm trying to compile a code that adds up a series of variables, then provides the arithmetic mean and displays the modulo result. I've been smashing my face against a Main() error that says "CS1520 Method must have a return type" and can't figure out what I'm doing wrong. My entire code is below. I know I'm code illiterate at the moment, so please be patient with me.

What I have tried:

C#
using System;
using System.Linq;

class Program
{
    static Main()
    {
        int number1, number2, number3;
        Console.Write("Enter an integer score");
        number1 = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter an integer score");
        number2 = Convert.ToInt32(Console.ReadLine());
        Console.Write("Enter an integer score");
        number3 = Convert.ToInt32(Console.ReadLine());

        int result = (number1 + number2 + number3) % 3;
        Console.WriteLine("The average of {0}, {1}, {2} is: {3}",
        number1, number2, number3, result);
    }
}
Posted
Updated 13-Mar-18 13:41pm
v2

1 solution

It needs to be static void Main().

If nothing returned its still needs a void declaration.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900