C
C#8mo ago
Ewan

✅ It says it must have a return type but idk how, help please!

No description
13 Replies
Angius
Angius8mo ago
Well, any method has to have a return type See how itemInfo() says it returns a string?
Ewan
EwanOP8mo ago
yes?
SG97
SG978mo ago
are you trying to create a constructor?
Angius
Angius8mo ago
Every method has to declare what it returns
SG97
SG978mo ago
for Menu
Angius
Angius8mo ago
If it returns nothing, it can be void
Ewan
EwanOP8mo ago
yes
Angius
Angius8mo ago
But it has to be some declaration $structure
MODiX
MODiX8mo ago
namespace Namespace;

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

public int PublicProperty { get; set; }

public Class() {} // Constructor

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

int LocalMethod(string param) { return 3; }
}
}
namespace Namespace;

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

public int PublicProperty { get; set; }

public Class() {} // Constructor

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

int LocalMethod(string param) { return 3; }
}
}
Ewan
EwanOP8mo ago
hmmm ok then
Angius
Angius8mo ago
If it's a constructor, then it should have the exact name as the class
SG97
SG978mo ago
Constructors - C# programming guide - C#
A constructor in C# is called when a class or struct is created. Use constructors to set defaults, limit instantiation, and write flexible, easy-to-read code.
Ewan
EwanOP8mo ago
OHH same name ok nvm got it thanks!
Want results from more Discord servers?
Add your server