37 lines
686 B
Plaintext
37 lines
686 B
Plaintext
include::../why-dotnet.adoc[]
|
|
|
|
include::../how-dotnet.adoc[]
|
|
|
|
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,csharp,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
bool ContainsEven(List<int> data) =>
|
|
data.Any(x => x % 2 == 0);
|
|
----
|
|
|
|
[source,csharp,diff-id=2,diff-type=noncompliant]
|
|
----
|
|
bool ContainsEven(int[] data) =>
|
|
data.Any(x => x % 2 == 0);
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,csharp,diff-id=1,diff-type=compliant]
|
|
----
|
|
bool ContainsEven(List<int> data) =>
|
|
data.Exists(x => x % 2 == 0);
|
|
----
|
|
|
|
[source,csharp,diff-id=2,diff-type=compliant]
|
|
----
|
|
bool ContainsEven(int[] data) =>
|
|
Array.Exists(data, x => x % 2 == 0);
|
|
----
|
|
|
|
|
|
include::../resources-dotnet.adoc[]
|