rspec/rules/S2197/csharp/rule.adoc
Arseniy Zaostrovnykh 7ca29f686f Force linebreaks
2021-02-02 15:02:10 +01:00

31 lines
352 B
Plaintext

include::../description.adoc[]
== Noncompliant Code Example
----
public bool IsOdd(int x)
{
return x % 2 == 1; // Noncompliant; if x is an odd negative, x % 2 == -1
}
----
== Compliant Solution
----
public bool IsOdd(int x)
{
return x %2 != 0;
}
----
or
----
public bool IsOdd(uint x)
{
return x %2 == 1;
}
----
include::../see.adoc[]