Does this server help with homework?
Hello, I'm new here and I would say that I'm new to C#, but I've been taking this course for about 4 weeks. Yet, I struggle very much with its concepts, I'm doing this assignment and I want to get as much done without looking up how other people have done the same assignment. Does this server allow for help or explanations on things like that?
28 Replies
Does it help with homework? Absolutely, yes.
Does it do homework for you? No, not a chance.
Thank you
Shall I make a new post dedicated to what I'm struggling with or can it be done here still?
Can go ahead here
Ok I'm trying to make it so that it asks the user for the base and exponent(power) then print the result
I want to keep
And what is the issue?
It doesn't work, I don't know where this should go
It should go into a method
Probably your
Main
method, as this is the first method that executes
And your PowerFunction
should be another method of the Program
class
Unless you did intend it to be a local function
Things become more clearer with syntax highlighting and proper formatting:
As you can see, a good chunk of your code is inside of the classYeah so I know that it won't work the way I did it
Let me think
What doesn't match between and
What do you mean "what doesn't match"?
Like should they both be able to get me an output if done correctly or is there something in the console.write box that is preventing that from happening?
The executable code should be inside of the main method
Instead, it's inside of the class
That is one of the issues
$structure
Classes can contain members. Fields, properties, methods
They don't actually run, they don't execute, they're just containers
Only methods inside of those classes run, execute
If you want code to run, it must me inside of a method
Code goes in method
Between the
{}
bracesI know it won't run but like this...
Yes, that's where code goes
And methods/functions go into classes
That's where
PowerFunction
should go
The opposite moveOk
So then I have to make it so that the integers equal to 0 right?
Which integers and why?
If you're asking if you need to do
then no, there's no need. It can just be
There's no need to assign a variable if you're gonna be reassigning it immediately after
I was meaning this
int = base 0;
Here?
Here?
Yes and for power and result too
Then maybe it could work in the order I had before
If you want to declare a variable, yes, the type of it does need to be declared. So
foo = 0;
won't work, while int foo = 0;
or var foo = 0;
will
It does not need to be assigned to immediately, though. As long as it is assigned to before you use it
So
will work
But
or
will notOh ok
I think that's gonna be it then
But before I go
I want for to ask for the base and exponent 5 times, will I need a loop for that?
Ideally, yes
You can just write the same code 5 times, sure, but a loop will make it easier
Ok got it, ty so much
goodbye
Anytime :Ok: