How do I use recursive methods and constructions together? [Answered]
i don't know what is wrong
51 Replies
what does the error message say?
Probably that there is no such method as
Power
accepting 2 parameters.No, that can't be it.
do you have a method called
Power
that takes 2 ints somewhere?You're talking about a runtime error while this can't compile.
I need to use fields inside power method
do that then
this ?
How can you reach there when you have a compile error?
not anymore i guess
Oh, there is that other method.
Can you $codegif the whole class please?
can i post all the code here, it's short already
StackOverFlow exception means there is a method that keeps calling itself infinitely
and Power keeps calling itself, infinitely
That's what I'm asking, but not as a screenshot, as $code
To post C# code type the following:
```cs
// code here
```
Get an example by typing
$codegif
in chat
If your code is too long, post it to: https://paste.mod.gg/i use google translate sorry for my misakes
what is the value of powernum?
i see the issue
3 i guess
you never used your parameters
It's weird. You're using fields while you don't need fields.
this is my homework
your not using your parameters, ur using your fields
how i use its?
I don't think a homework would be as specific as saying "be recursive, but use fields not parameters".
remove
this.
And I would say remove the fields all together. Even make the method static I think.
yeah
my teacher likes hard questions
It's not about it being hard. It's just a bad design imo. Do you have the verbatim question somewhere? What language is it in?
then how do i use the fields?
(Gotta make a work call, but I'll check back in after)
By keeping
this.
...hmm
if you want to use fields your method doesnt need parameters
i'll wait
Can't fields take parameters?
because ur basically passing arguments to the method, but you never used them
if you mean assigning a value to fields, you can
I don't know how to use them
what is your goal? and why do you need fields?
i need power calculator with recrusive methods and constructions
yes but why do u need fields?
because we learned these topics in the lesson and I have to write this code using them
did they tell you in the lesson to use the method's parameters?
i think so
i can simulate how your code is working now
yes pls
omg
im a dump
then I have to delete the filedlari and use only recursive methods
✅ This post has been marked as answered!