Reputation: 33
I want to expand condition if checkbox is checked is it possible?
string Condition= "A==B"
if (chechbox1.Checked==true)
{
Condition+="&& B==C";
}
if (chechbox2.Checked==true)
{
Condition+="&& C==D";
}
if (Condition)
{
//do something
}
Upvotes: 0
Views: 63
Reputation: 25370
use boolean logic:
bool Condition = A == B;
if (chechbox1.Checked)
{
Condition &= B == C;
}
if (chechbox2.Checked)
{
Condition &= C == D;
}
if (Condition)
{
//do something
}
Upvotes: 2
Reputation: 103447
Not using strings, but there's no reason you can't do this directly:
bool Condition = (A == B);
if (chechbox1.Checked)
{
Condition = Condition && (B == C);
}
if (chechbox2.Checked)
{
Condition = Condition && (C == D);
}
if (Condition)
{
//do something
}
Upvotes: 1