views:

161

answers:

3

Hi there

I am getting a StackOverflow Error in this code:

EDIT

[XmlAttribute("ID")]
public string ID { get; set; }

EDIT2

 public ParameterEntity this[string szID]
    {
        get
        {
            //Finds the parameter entity with the ID passed in.
            return rParameters.Find(
                  delegate(ParameterEntity oParameterEntity)
                  {
                      return oParameterEntity.ID.Equals(szID, StringComparison.OrdinalIgnoreCase);
                  });
        }
    }

Can you guys please advise?

I might just have to use a simple manual looping.

Thanks -Oliver

A: 

Can you show the getter of ID property?

Why do you use .ToLower() method? I think, the using of System.String ids is not a good practice.

madcyree
+1  A: 

It's likely your ID property is trying to return itself, or set itself

Something like

private int _ID;

public int ID{
   get{return ID;}
   set{ID=value;}
}

Obviously it's probably not something that simple, but along those lines

(many edits ;P)

qui
I have done something like this too many times!
Martin
A: 

Problem was elsewhere.

Oliver
A common problem with a stack overflow exception is not the drop that made the water in the glass spill over the edges, but all those drops before it that made the glass almost full. Typically you have a long stackframe with the actual recursion problem, and then an innocent looking method call that triggers the exception. The problem is not that method, but the recursive path before it.
Lasse V. Karlsen
Agreed, This was in an infrastructure class that was being called by another member of my team and he had a recursive method. So after much investigation it turned out to be a problem his side.
Oliver