How do I create layers (a.k.a. OCGs - Optional Content Groups) using PDFNet?

Q: I would like to use PDFNet SDK to implement Optional Content Group
(i.e. PDF Layers). I read the topic "Using PDFNet to work with PDF
Layers and optional content (OC) groups" in KB, but I didn't find the
attached example of a PDF document with
layers or code example. Could you please give me a complete code

Attached is a sample project demonstrating how to create PDF documents
with Layers (i.e. OCG - Optional Content Groups). The sample is
written in C++ (to run it you could copy any of the command-line
samples in the Samples folder and then add 'PDFLayersTest.cpp' to the
solution). In case your are developing using C# or Java, please let us
know so that we can provide you with a specific version.

Sample code:

Generated PDF document with Layers: