diff --git a/Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value/Program.cs b/Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value/Program.cs index 32c8a3496..424e919a3 100644 --- a/Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value/Program.cs +++ b/Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value/Program.cs @@ -19,17 +19,15 @@ static void Main(string[] args) document.GetText(); //Find all paragraphs with the style 'Heading 3' in the Word document. List headingParagraphs = document.FindAllItemsByProperty(EntityType.Paragraph, "StyleName", "Heading 3"); - if (headingParagraphs.Count == 0) + if (headingParagraphs == null) Console.WriteLine("No paragraphs with the style 'Heading 3' found."); else { - foreach (Entity paragraph in headingParagraphs) - { - //Get the string that represents the appearance of list value of the paragraph. - if (paragraph is WParagraph) - Console.WriteLine((paragraph as WParagraph).ListString); - else - Console.WriteLine("The entity is not a WParagraph."); + foreach (Entity entity in headingParagraphs) + { + WParagraph paragraph = entity as WParagraph; + //Get the heading number and the heading text together. + Console.WriteLine(paragraph.ListString + paragraph.Text); } } //Pauses the console to display the output.