16 Replies
please reformat your code
Now, looks much better.
Do you know what
void
means?
Your issue is that RäknaBokstäver
returns void
, and you're trying to assign it to int
.Oh! Sorry, I forgot that part.
Yes, void is not a return method.
I think you probably want
RäknaBokstäver
to return int
, because it should, well, count the amount of lettersOk
How about these the declaration of these variables int antalOrd, summa; ?
Well, your second issue is that
summa
is not a variable in the RäknaBokstäver
method, because you haven't declared it there. You can solve this quite simply, by just declaring summa
inside RäknaBokstäver
.Ok! You're right it makes sense.
Is there more issues except for the void and summa?
Not in terms of errors at least
There are some faults in your logic, and some minor style nitpicks, however nothing terrible.
Ok! Could you please point at these issues?
For example the if and else are missing curly brackets
actually there is one error, you're declaring
summa
twice, once at the top of Main
and once inside the if
You also need braces around the int summa = ...
and Console.WriteLine("Alla ord du har...
linesHow to solve this issue?
Well, declare it only once
Think about where you actually need the variable.
You're only using it twice, once when you assign to it, and once when you use it in a Console.WriteLine
Ok
Thanks a lot man, I really appreciate your effort of helping me and the others 🙏 🙂
I learned a several things from this project
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.