Aspose.Words.Examples.CSharp.Programming_Documents.Working_with_Styles.ExtractContentBasedOnStyles.ParagraphsByStyleName C# (CSharp) Метод

ParagraphsByStyleName() публичный статический Метод

public static ParagraphsByStyleName ( Document doc, string styleName ) : ArrayList
doc Document
styleName string
Результат System.Collections.ArrayList
        public static ArrayList ParagraphsByStyleName(Document doc, string styleName)
        {
            // Create an array to collect paragraphs of the specified style.
            ArrayList paragraphsWithStyle = new ArrayList();
            // Get all paragraphs from the document.
            NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
            // Look through all paragraphs to find those with the specified style.
            foreach (Paragraph paragraph in paragraphs)
            {
                if (paragraph.ParagraphFormat.Style.Name == styleName)
                    paragraphsWithStyle.Add(paragraph);
            }
            return paragraphsWithStyle;
        }
        // ExEnd:ParagraphsByStyleName