Array.Find or Predicate use in X#
Posted: Fri Aug 12, 2016 3:07 am
The prototype of the static method Array.Find is as follows:
and a C# sample is this:
The X# code is as follows:
As you can see, the codeblock syntax works also in this case.
Code: Select all
public static T Find<T>(
T[] array,
Predicate<T> match
)
Code: Select all
string [] arr = {"One","Two","Three"};
var results = Array.FindAll(arr, s => s.Equals("One"));
Code: Select all
local aString as string[]
aString := <string>{ "one", "two", "three", "four" }
var cFind := Array.Find( aString, {|c| c == "two" } )