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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:44:40+00:00 2026-05-14T08:44:40+00:00

I was just playing around with some code in LINQPad and managed to crash

  • 0

I was just playing around with some code in LINQPad and managed to crash the program with a stackoverflow exception.

I basically created a static property in a field and used a property to return the value from an instance.

The getter of my instance property would return the value of the static field, but the setter would set itself. When would this type of pattern be used and how come it generated a stackoverflow exception?

Code example of what I did:

void Main()
{
    SomeClass myinstance = new SomeClass();
    SomeClass.x = "Some Value";
    myinstance.y = "Some other value";
    myinstance.y.Dump();
}

public class SomeClass
{
    public static string x;

    public string y
    {
        get { return x; }
        set { y = value; }
    }
}
  • 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-14T08:44:40+00:00Added an answer on May 14, 2026 at 8:44 am

    This is the first thing I ever did with properties 🙂 — you’re recursively calling the y setter rather than setting a backing field. Since it calls itself, it will eventually stackoverflow.

    Each setter is syntactic sugar and is basically a method call. What you’ve done is basically equivalent to doing this with a method:

    public class SomeClass
    {
       public string GetValue() { return "some string"; }
       public void SetValue(string arg)
       { 
           SetValue(arg); // recursively calls itself until stackoverflow
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some sample code i have been playing around with. Basically im just
I'm just playing around with some code. I create an Activity and simply do
I'm just playing around with some code but it seemed to have the specific
Just playing around with some sample code and hit on an unexpected problem with
Just playing around with some of the APIs in .NET and I can't seem
I'm just playing around with a simple program that opens the camera. That's literally
I am playing around some in C++, just for fun. I have just begun
This is a rather naive question. I'm just playing around with allocating some executable
I'm just getting into RSpec and playing around a bit with some easy examples
This surprised me a little bit, but I was playing around with some code

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.