What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

stackoverflow in class

etmawow

New Member
Joined
May 2, 2010
Messages
79
Reaction score
1
Hi..

Feels like I'm posting here almost every day now :P

I've made this class, but whenever I try to set a value in it, honorbuddy exits with an stackoverflow error

Code:
private class steps
        {
            public int stepId { get { return stepId; } set [B]{[/B] stepId = value; } }
            public int questId { get { return questId; } set { questId = value; } }
            public string questName { get { return questName; } set { questName = value; } }
            public string action { get { return action; } set { action = value; } }
        }
the stack overflow is at the bold {, at the first set.. (according to debugging in Visual studio .NET 2010)

Hope someone can help :)
 
Last edited:
had to rewrite it to this. However, if someone can help me with why the other failed, I'd love to hear it :)

Code:
public class steps
    {

        private int stepId;
        private int questId;
        private string questName;
        private string action;

        public int getStepId()
        {
            return stepId;
        }
        public void setStepId(int newStepId)
        {
            stepId = newStepId;
        }
        public int getQuestId()
        {
            return questId;
        }
        public void setQuestId(int newQuestId)
        {
            questId = newQuestId;
        }
        public string getQuestName()
        {
            return questName;
        }
        public void setQuestName(string newQuestName)
        {
            questName = newQuestName;
        }
        public string getAction()
        {
            return action;
        }
        public void setAction(string newAction)
        {
            action = newAction;
        }
        
    }
 
oh well.. found out why :)

if ppl are curious, one should either use
public int MyProperty { get; set; }
to use it implimented, or use the normal way
private int MyInt;

public int MyProperty
{
get { return MyInt; }
set { MyInt = value; }
}

:)
 
public int stepId { get { return stepId; } set { stepId = value; } } <- This is a recursive call. Basically that is like:
int GetStepId()
{
return GetStepId();
}

or

void SetStepId(int value)
{
SetStepId(value);
}
 
Back
Top