Visual C# Developer Center > Visual C# Forums > Visual C# General > List<T> Element Character Limit Problem
Ask a questionAsk a question
 

AnswerList<T> Element Character Limit Problem

  • Tuesday, November 03, 2009 4:17 PMEvren Betimen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Is there any way to fix it? My List<T> Collection doesnt add 1,227 Character (with spaces) Element but 173 Character Element is being added. How could it be?

    Thanks in advance,
    Greetings


    "to code or not to code!"

Answers

  • Tuesday, November 03, 2009 4:55 PMReed Copsey, Jr. Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    I think the problem is your first for loop.  Try changing it to:

    for (int i = 0; i < mc.Count; i++)
    {
        lst.Add(mc[i].Groups[1].ToString());
    }
    
    
    

    Otherwise, you'll get very odd behavior (effectively skipping elements), which might explain your issue.
    Reed Copsey, Jr. - http://reedcopsey.com

All Replies

  • Tuesday, November 03, 2009 4:42 PMRudedog2ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    It should not do that.
    We have no idea why it happens in your code, mainly because we cannot see it.

    Post some of your code that reproduces the problem so that someone can take a look.
    Help someone to help you.

    Rudy   =8^D

    Mark the best replies as answers. "Fooling computers since 1971."
  • Tuesday, November 03, 2009 4:48 PMEvren Betimen Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
                    foreach (Match m in Regex.Matches(myString, DescriptionTag))
                    {
                        MatchCollection mc = Regex.Matches(myString, DescriptionTag);
                        for (int i = lst.Count; i < mc.Count; i++)
                        {
                            lst.Add(mc[i].Groups[1].ToString());
                        }
    
                    }
    
                    for (int i = 0; i < lst.Count; i++)
                    {
                        MessageBox.Show(lst[i].ToString());
                    }
    
    lst[2] is okay with 173 characters string. But it is passing directly to lst[3] as lst[2] when string is 1,227 characters. I think my code doesn't read at that character size.
    "to code or not to code!"
  • Tuesday, November 03, 2009 4:55 PMReed Copsey, Jr. Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    I think the problem is your first for loop.  Try changing it to:

    for (int i = 0; i < mc.Count; i++)
    {
        lst.Add(mc[i].Groups[1].ToString());
    }
    
    
    

    Otherwise, you'll get very odd behavior (effectively skipping elements), which might explain your issue.
    Reed Copsey, Jr. - http://reedcopsey.com