© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
12 replies
Melton

if statements with more than once condition

Hi, I'm struggling a bit with figuring out how to add ranges as conditions in my if/else if statements. Rather than having conditions being above, below, or equal to X, I want to be able to find whether or not a statement fits a very specific condition.
How would you proceed with this problem? This is where I get stuck:
int a = 10;
int b = 10;
int c = 10;
int d = 10;

int x = a + b + c + d;

Random random = new Random();
int numberFinder = random.Next(0, x);

string 1 = "The number is 10 or lower";
string 2 = "The number is between 11 and 20";
string 3 = "The number is between 21 and 30";
string 4 = "The number is 31 or higher";

if ( numberFinder <= a )
{
    Console.Writeline(1);
}
else if ( numberFinder ????????????????????
int a = 10;
int b = 10;
int c = 10;
int d = 10;

int x = a + b + c + d;

Random random = new Random();
int numberFinder = random.Next(0, x);

string 1 = "The number is 10 or lower";
string 2 = "The number is between 11 and 20";
string 3 = "The number is between 21 and 30";
string 4 = "The number is 31 or higher";

if ( numberFinder <= a )
{
    Console.Writeline(1);
}
else if ( numberFinder ????????????????????
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Blazor - Event executed more than once
C#CC# / help
3y ago
If statements
C#CC# / help
3y ago
Branching if statements
C#CC# / help
3y ago