O'Reilly logo

Extending Microsoft Dynamics NAV 2016 Cookbook by Alexander Drogin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

  1. 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.
  2. In the page designer, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required