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 9290317
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T20:23:30+00:00 2026-06-18T20:23:30+00:00

I am trying to extract the first 200 words of a string and sometimes

  • 0

I am trying to extract the first 200 words of a string and sometimes I get the following error:

"Index and length must refer to a location within the string. Parameter name: length"

The code is:

int i = GetIndex(fullarticle, 200);
string result = fullarticle.Substring(0, i);

How do I fix this?

  • 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-06-18T20:23:31+00:00Added an answer on June 18, 2026 at 8:23 pm

    It appears safe to assume the error is coming from string.Substring. Given that you get this error when startIndex + length > given.Length or startIndex < 0 or length < 0, GetIndex is either returning a value greater than fullarticle.Length or a negative number. The error exists in GetIndex so if you wish to carry on with the code you have, you should post the code of GetIndex to get the best answer.

    If you’re up for something different, you could try this:

    static string GetShortIntroduction(string phrase, int words)
    {
        // simple word count assuming spaces represent word boundaries
        return string.Join(" ", phrase.Split().Take(words));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to extract the first user-right from semicolon separated string which matches a
I am trying to extract the first words in a file by Python. My
I'm trying to extract all words from a string into an array, but i
I am trying to extract a string that is located between the first and
I'm trying to use the following line to extract the first file in a
I am getting the first paragraph from pages and trying to extract words suitable
I'm trying to extract the last two digits in a string. First I remove
I'm working in C#. I'm trying to extract the first instance of img tag
I am trying to extract the first letter of every word for a sentence
I'm trying to extract first paragraph. But I have found any luck. Can any

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.