File tree Expand file tree Collapse file tree 1 file changed +6
-8
lines changed
Paragraphs/Get-heading-list-value/.NET/Get-heading-list-value Expand file tree Collapse file tree 1 file changed +6
-8
lines changed Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments