34 lines
774 B
Plaintext
34 lines
774 B
Plaintext
=== Code examples
|
|
|
|
==== Noncompliant code example
|
|
|
|
[source,vbnet,diff-id=1,diff-type=noncompliant]
|
|
----
|
|
Function GetValue(data As List(Of Integer)) As Integer
|
|
Return data.FirstOrDefault(Function(x) x Mod 2 = 0)
|
|
End Function
|
|
----
|
|
|
|
[source,vbnet,diff-id=2,diff-type=noncompliant]
|
|
----
|
|
Function GetValue(data() As Integer) As Integer
|
|
Return data.FirstOrDefault(Function(x) x Mod 2 = 0)
|
|
End Function
|
|
----
|
|
|
|
==== Compliant solution
|
|
|
|
[source,vbnet,diff-id=1,diff-type=compliant]
|
|
----
|
|
Function GetValue(data As List(Of Integer)) As Integer
|
|
Return data.Find(Function(x) x Mod 2 = 0)
|
|
End Function
|
|
----
|
|
|
|
[source,vbnet,diff-id=2,diff-type=compliant]
|
|
----
|
|
Function GetValue(data() As Integer) As Integer
|
|
Return Array.Find(data, Function(x) x Mod 2 = 0)
|
|
End Function
|
|
----
|