Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7409013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:00:36+00:00 2026-05-29T06:00:36+00:00

How can I count number of sentences in a given string?

  • 0

How can I count number of sentences in a given string?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T06:00:37+00:00Added an answer on May 29, 2026 at 6:00 am

    If you already have Word installed, you can use Word interop to get the sentence count, as well as other statistics. This also has the benefit of potentially working with other languages besides English.

    object oMissing = System.Reflection.Missing.Value;
    
    var oWord = new Microsoft.Office.Interop.Word.Application();
    oWord.Visible = false;
    var oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
    
    oDoc.Content.Text = inputTextBox.Text;
    
    //get just sentence count
    sentenceCountLabel.Text = oDoc.Sentences.Count.ToString();
    
    //get all statistics
    foreach (Microsoft.Office.Interop.Word.ReadabilityStatistic stat in oDoc.ReadabilityStatistics)
    {
        Console.WriteLine("{0}: {1}", stat.Name, stat.Value);
    }
    
    object oFalse = false;
    
    oDoc.Close(ref oFalse, ref oMissing, ref oMissing);
    

    This will output:

     Words: 283 
     Characters: 1271 
     Paragraphs: 3 
     Sentences: 6 
     Sentences per Paragraph: 2 
     Words per Sentence: 47.1 
     Characters per Word: 4.3 
     Passive Sentences: 0 
     Flesch Reading Ease: 55.2 
     Flesch-Kincaid Grade Level: 12.5
    

    This may not be the most efficient, but it only requires a few lines of code and may be suitable depending on your needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how can I count the number of integers in a string using jQuery or
I have a table and can count the number of rows using var count
I would like to know how I can count the number of unique values
In the 10 years I've been programming, I can count the number of data
How can I count the number of elements in an array, because contrary to
How can i count the number of stored procedures in my database and is
How can I count the number of files in a directory using C on
Is there a way I can programmatically count the number of links for a
I can not seem to figure out how to count the number of seconds
I'm trying to figure out how I can count the number of div's inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.