35 lines
563 B
Plaintext
35 lines
563 B
Plaintext
If the same logic is truly needed for both instances, then:
|
|
|
|
* in an `if` chain they should be combined
|
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
|
----
|
|
if ((a >= 0 && a < 10) || (a >= 20 && a < 50))
|
|
{
|
|
DoFirst();
|
|
DoTheThing();
|
|
}
|
|
else if (a >= 10 && a < 20)
|
|
{
|
|
DoTheOtherThing();
|
|
}
|
|
----
|
|
|
|
* for a `switch`, one should fall through to the other
|
|
|
|
[source,csharp,diff-id=2,diff-type=compliant]
|
|
----
|
|
switch (i)
|
|
{
|
|
case 1:
|
|
case 3:
|
|
DoFirst();
|
|
DoSomething();
|
|
break;
|
|
case 2:
|
|
DoSomethingDifferent();
|
|
break;
|
|
default:
|
|
DoTheRest();
|
|
}
|
|
---- |