C
C#17mo ago
daniel1

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

.
7 Replies
daniel1
daniel117mo 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
Angius17mo ago
Show all of your code Although it seems the error is quite self-explanatory $codegif
daniel1
daniel117mo 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
Angius17mo 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
daniel117mo ago
i guss i miscaculated thenk you for the help
Accord
Accord17mo 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.