C
C#8mo ago
Shunrai

✅ Attempting to create a method throws CS0116?

Brothers, everything was working fine on the previous projects I started. Now for some reason I am getting CS0116 error on my method that I am trying to create and I can't figure out why. Any ideas?
using System;

namespace _08.MathPower
{
internal class Program
{
static void Main(string[] args)
{

Console.WriteLine("Hello World!");
}
}
static int OperatorMethod(int a, int b) //This
{
return a+b;
}
}
using System;

namespace _08.MathPower
{
internal class Program
{
static void Main(string[] args)
{

Console.WriteLine("Hello World!");
}
}
static int OperatorMethod(int a, int b) //This
{
return a+b;
}
}
5 Replies
Shunrai
Shunrai8mo ago
even pasting methods from my other projects doesn't work 😦 Praying for brother ZZZZZZZZZ to bless this thread pepepray
Angius
Angius8mo ago
Methods go into classes Classes go into namespaces Methods don't go into namespaces $structure
MODiX
MODiX8mo ago
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;
protected double protectedField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;
}
}
namespace Namespace;

[Attribute]
public class Class
{
public string PublicField;
private bool _privateField;
protected double protectedField;

public int PublicProperty { get; set; }

public Class() {} // Constructor

public void Method(int parameter)
{
var localVariable = parameter;
}
}
Shunrai
Shunrai8mo ago
Oh Facepalm you for blessing this thread brother pepepray
Angius
Angius8mo ago
No problem lol