How to know the document contains TOC or not.
Here is a sample code to check if it has TOC fields or not.
// check if there are ToC fields
var tocFields = doc.Range.Fields.Where(f => f.Type == FieldType.FieldTOC);
if (tocFields.Any())
Console.WriteLine("Has ToC elements");
else
Console.WriteLine("Does not has ToC elements");