Skip to content

Commit 054dab2

Browse files
Merge pull request #490 from SyncfusionExamples/965406-Modify-Extract-list-values-from-headings
965406 - Enhance sample to retrieve headings with numbers
2 parents 1094fa0 + 97b94a0 commit 054dab2

File tree

1 file changed

+6
-8
lines changed
  • Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value

1 file changed

+6
-8
lines changed

Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value/Program.cs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@ static void Main(string[] args)
1919
document.GetText();
2020
//Find all paragraphs with the style 'Heading 3' in the Word document.
2121
List<Entity> headingParagraphs = document.FindAllItemsByProperty(EntityType.Paragraph, "StyleName", "Heading 3");
22-
if (headingParagraphs.Count == 0)
22+
if (headingParagraphs == null)
2323
Console.WriteLine("No paragraphs with the style 'Heading 3' found.");
2424
else
2525
{
26-
foreach (Entity paragraph in headingParagraphs)
27-
{
28-
//Get the string that represents the appearance of list value of the paragraph.
29-
if (paragraph is WParagraph)
30-
Console.WriteLine((paragraph as WParagraph).ListString);
31-
else
32-
Console.WriteLine("The entity is not a WParagraph.");
26+
foreach (Entity entity in headingParagraphs)
27+
{
28+
WParagraph paragraph = entity as WParagraph;
29+
//Get the heading number and the heading text together.
30+
Console.WriteLine(paragraph.ListString + paragraph.Text);
3331
}
3432
}
3533
//Pauses the console to display the output.

0 commit comments

Comments
 (0)