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

  • Home
  • SEARCH
  • 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 362253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:13:36+00:00 2026-05-12T13:13:36+00:00

I am not sure what is causing the StackOverflowException when I try to overwrite

  • 0

I am not sure what is causing the StackOverflowException when I try to overwrite a get and set function. When I just use the default get and set it works.

enum MyEnumType
{
....
}

public MyEnumType data { get; set; }

But when I try to add additional data, it throws a StackOverflowException:

public MyEnumType data
{
  get
  {
    return data;
  }
  set
  {
    data = value;
  }
}

Any ideas? When I do this for ASP.NET user control attributes there isn’t any problem. Why is it is causing a StackOverflowException for a normal enum data type?

  • 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-12T13:13:37+00:00Added an answer on May 12, 2026 at 1:13 pm

    Yes, you do not have a backing field… this is how you should do it:

    private MyEnumType data;
    
    public MyEnumType Data
    {
      get
      {
        return data;
      }
      set
      {
        data = value;
      }
    }
    

    What happens is that you are referring to the property to return itself, which causes an infinite loop of trying to access its own value. Hence, a stack overflow.

    In your case when you do not add any additional logic in the get and set methods you could use an automatic property as well. This is simply defined like so:

    public MyEnumType Data
    {
      get;
      set;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 165k
  • Answers 166k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Basically, you would need to build the functionality yourself. You… May 12, 2026 at 1:14 pm
  • Editorial Team
    Editorial Team added an answer It may be that StretchDIBits expands the source image into… May 12, 2026 at 1:14 pm
  • Editorial Team
    Editorial Team added an answer Try this http://rebol.wik.is/Protocols/Http May 12, 2026 at 1:14 pm

Related Questions

I have a Javascript function that returns the innerHTML of a div. I am
My SQL Server CPU has been at around 90% for the most part of
I keep getting a PermGen error on my Tomcat 6 server. I know what
I am writing an assignment in MASM32 Assembly and I almost completed it but
I have a java program that runs a bunch of queries against an sql

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.