+ 3
What is the mistake on this code?
3 Answers
+ 7
your function is both a void and an int but it can only be one of them and in your case it's need to be a void
+ 2
The error was because you added an operator before your method name "sum"
...here's your code without errors
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SoloLearn
{
class Program
{
static void Sum(int x, int y)
{
Console.WriteLine(x+y);
}
static void Main(string[] args)
{
Sum(8, 6);
}
}
}
0
I go with what Johan said. You can't have a function return both none and a number. It has to be a void in your case.