53 Replies
my attempts so far consits of
public static bool (int num = 0)
You need to give the method a name
public static bool MethodName(int num = 0)
i tried
public static bool op(int num = 0)
its still red
You need curly braces after
"not all code paths return a vaule
ahhh
"
you need to return a bool
for example
return true;
public static bool op(int num = 0)
{
if (num > 3)
{
return "a";
}
}
thats a string
you can just
return num > 3;
what do you mean by that
thats true if num is greater then 3 otherwise false
you sure thats how it should be
your not returning anything tho
i need to return a massage
i dont know what you want to archieve with this method
let me send you the task
then you have to change the return type
one moment
Methods - C# Guide
Overview of methods, method parameters, and method return values
In a certain city it was determined that a building with more than 3 floors must have an elevator. Write an action
that you get a whole number greater than 0, representing the number of floors in the building. The operation will return the character 'a' if required
There must be an elevator in the building, otherwise the operation will return the character 'b.'
Okay so you could do something like this:
what does char mean
char is a character
do i need to use char for this
you can also use string
A char is a single character
A string is a char array
I'd say use char, thats what it seems the task expects.
The operation will return the character 'a' if requiredsingle quotes like that are only used for chars in C#
Yeah then char
return floors > 3 "a";
this is not working
its all red
"a" is a string, not a char
and also not a valid syntax
read BlyZe's code snippet again.
it still dosent work
why cant i use bool with it
what is a bool?
what values can a bool represent?
i dont know
then why do you want to use a bool?
but char is not working ethir
yes it is, if you write it correctly
BlyZe#3482
Okay so you could do something like this:
Quoted by
<@!105026391237480448> from #how do i use functions like for example "public static bool (int num = 0)" (click here)
React with ❌ to remove this embed.
this will 100% work just fine
you sure my teacher will accept this
she taught us to use bool and stuff
The task description clearly states that the method should return a char
but you do you
and absolutely do not copypaste the code Blyze sent
it will be more than obvious that you did not write it
You don't really seem to be wanting to learn, only cheat on your homework?
i have an exam tomrow
this homework is not graded its just that if you cant to do the home work you probably fail the exam
its 10 pm right now
Programming isn't really something you learn in a single evening, just saying.
i know
i havent done it for three months beacuse our teacher got into a car accidents and we were bombered with exams on every single other subject
Well, the truth is, that regardless of that you can't learn programming if you only do it during class
my 11th grade class is harder compared to other 11th grade classes in my country/ school
2x45 minutes a week or however much is nothing
i know
thats why i am sitting here
A day before exam
Well, it's better than nothing I guess
That said, you can easily worsen this code to school levels by using an if-else instead of the ternary
i could have studied yestarday but i had an exam yesterday in maths and it does sound like an excuse beacuse it is but i decided that beacuse i handeled that math exam so well i deserved to only study one day before the exam
you should follow $helloworld
Written interactive course https://learn.microsoft.com/en-us/users/dotnet/collections/yz26f8y64n7k07
Videos https://dotnet.microsoft.com/learn/videos
I think it's very valuable
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.