C
C#3mo ago
Ewan

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

No description
13 Replies
Angius
Angius3mo ago
Well, any method has to have a return type See how itemInfo() says it returns a string?
Ewan
Ewan3mo ago
yes?
SG97
SG973mo ago
are you trying to create a constructor?
Angius
Angius3mo ago
Every method has to declare what it returns
SG97
SG973mo ago
for Menu
Angius
Angius3mo ago
If it returns nothing, it can be void
Ewan
Ewan3mo ago
yes
Angius
Angius3mo ago
But it has to be some declaration $structure
MODiX
MODiX3mo 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
Ewan3mo ago
hmmm ok then
Angius
Angius3mo ago
If it's a constructor, then it should have the exact name as the class
SG97
SG973mo 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
Ewan3mo ago
OHH same name ok nvm got it thanks!
Want results from more Discord servers?
Add your server
More Posts
Maui API IMPLEMENTHi i am making maui app which can track stocks. I want to use yahoo finance api from rapidapi but i What should the service layer return back to a controller?Confused about what the service layer should return to the controller, Dtos? Result object? Is thiBlazor WSAM with Cognito Hosted UI issuesHey there, I'm slightly struggling with getting Blazor WebAssembly to work with Cognito. I created a✅ how to take out items in a string into an array and making it work for other strings?Ive been trying to take out the topping items and put them in an array from this line of string but How to resolve this exception```csharp System.TypeInitializationException: The type initializer for 'Azure.Core.ClientOptions' tThe combination of `StringEnumConverter` and `EnumMember` does not workI try to have "speaking values" for my enum values in a JSON file. I tried combining the both annota✅ Calling base of subscribed method results in a StackOverflowExceptionI'm trying to override an `OnExiting` method, however trying to call `base.OnExiting()` within that Control for showing icons (.ICO files) (WinForms .Net 8)I'm an old Delphi developer that recently is enjoying the passage to .Net and C#. I was used to haveDo I have to target specific runtimes? (I used to be able to have one installer for everyone)When I use "Publish Selection" in visual studio, I appear to have to choose a target runtime. I woul✅ Is this how you are supposed to use .select() EF CORE```c# // GET: api/Venture/5 [HttpGet("{id}")] public async Task<ActionResult<VentureDto>> Ge