Hod do I remove OCG-s from PDF?

Q: my interest in the PDF SDK (http://www.pdftron.com/pdfnet) resides
around the OCG removal option.
is there any sample code for removing an OCG??
A: You can use PDFNet to remove OCG (Optional Content Groups) from
PDFs. As a starting point you may want to take a look at PDFLayers
sample project (www.pdftron.com/pdfnet/samples.html).

Probably the simplest way to remove OCG information from a PDF is
using the following line:

Q: I looked at the sample project, but it shows only how to add OCGs.

This is my reason for asking:
I have a large database of documents in PDM system, every night a
script passes over the documents and adds a watermark (with acrobat
standard SDK) on each new PDF specifying it's Item status (Active /
Prototype...). I usually keep an unmarked file and if an item changes
status the watermark is added on the unmarked file, but in some cases
there is no unmarked file.
My current bypass in with user interface keypress in acrobat 8 -
watermark remove menu.

I know I can flatten the OCG layer with PDFNet SDK (OCG Destroy) but I
need to remove the layer - just like the user menu does.

Reading the PDFNet API reference is HTML is pretty hard, and I
couldn't find any "erase" command.
Any help would be appreciated.
A: To remove layers selectively you could delete specific entries from
the OCG array (instead of deleting the entire array). For example, the
following snippet could be used to remove the last entry in OCG array
for the document.

Obj ocg_array = pdfdoc.GetGetOCGs();
if (ocg_array != null && ocg_array.Size()>0) {

is HTML is pretty hard, and I couldn't find any "erase" command.

If you are developing on Windows you could download HTML/CHM help
documentation (http://www.pdftron.com/pdfnet/downloads.html) which
offers integrated search option.

Obj.Erase(key) and Obj.EraseAt(idx) are members of pdftron::SDF::Obj.
The former is used to delete a key/value entry from a dictionary Obj,
whereas the latter is used to remove an entry from an array Obj. If
you obtain the type of Obj you are dealing with using Obj.GetType().