Working with generics in C/AL
Generic classes and methods in .NET Framework are a powerful tool allowing more extensive code reusability, while keeping the code type-safe. Generics enable the code to defer type specification until the moment of instantiation of the generic class.
To use generics in C/AL, you can declare variables of the DotNet type and bind them to one of the classes from the System.Collections.Generic
namespace.
How to do it...
In this recipe, we will use a generic List
class to find an item in a collection with the closest match to a provided search pattern.
Create a blank page in the object designer. No page wizard is required, since the page will not present any database controls and is not bound to any table.
In the page designer, enter a name for the default
ContentArea
container and insert aField
element under the container.Declare a global
Text
variableSearchText
. EnterSearchText
in theSourceExpr
property of the text control.Create a C/AL
Search
function. The function...