C
C#2y ago
daniel1

❔ i am trying to combine methods with public static void main and its faling horibly

.
7 Replies
daniel1
daniel1OP2y ago
public static void main(int age, int hours, int c = 0) whats wrong about it "a name space cannot directley contain members such as fields or methods "
Angius
Angius2y ago
Show all of your code Although it seems the error is quite self-explanatory $codegif
daniel1
daniel1OP2y ago
public class Program { public static bool check(int age) { if (age <= 18 && age >= 15) { return true; } else { return false; } } } public static void main(int age, int hours, int c = 0)
{ } } sorry for the late response i just thought i should be abele to use both of them in the same program otherwise whats the point in using bool
Angius
Angius2y ago
So, let's clean up the code a little
public class Program
{
public static bool check(int age)
{
if (age <= 18 && age >= 15)
{
return true;
}
else
{
return false;
}
}
}

public static void main(int age, int hours, int c = 0)
{

}
}
public class Program
{
public static bool check(int age)
{
if (age <= 18 && age >= 15)
{
return true;
}
else
{
return false;
}
}
}

public static void main(int age, int hours, int c = 0)
{

}
}
Do you see the issue?
daniel1
daniel1OP2y ago
i guss i miscaculated thenk you for the help
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server