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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:07:01+00:00 2026-05-27T16:07:01+00:00

I have this register that registers all the objects I need: public static class

  • 0

I have this register that registers all the objects I need:

public static class ObjectRegister
{
    public static List<IObject> RegisteredObjects = new List<IObject>();
    static ObjectRegister()
    {
        RegisteredObjects.Add(new Object1());
        RegisteredObjects.Add(new Object2());
        RegisteredObjects.Add(new Object3());
    }
}

Next I have this function that checks a list and if the items in the list pass the test, it creates an object instance and adds it to the list:

public static List<IObject> Scan(List<parametar> list)
    {
        List<IObject> neededObjects = new List<IObject>();
        foreach (IObject registeredObject in ObjectRegister.RegisteredObjects)
        {
            foreach (parametar param in list)
            {
                if (registeredObject.Test(param)) //returns true or false 
                {
                    neededObjects.Add(registeredObject.CreateInstance(param));
                }
            }
        }
        return connectedObjects;
    }

Here is the CreateInstace method for Object1:

public IObject CreateInstance(parametar param)
    {
        return new Object1(param);
    }

And here is the constructor:

public Object1(parametar newParam)
    {
        this.param = newParam;
    }

It keeps trowing StackOverflow exception on this line:

this.param = newParam;

Tried all the possibilities for creating an instance, default constructor, empty object etc etc, but nothing worked… any ideas?

Thanx

EDIT:
Code to the Object1 class:

public class Object1: IObject
{
    public parametar param
    {
        get { return this.param; }
        set { this.param = value; }
    }

    internal Object1() { }

    public Object1(parametar newParam)
    {
        this.param = newParam;
    }        


    public bool test(parametar param)
    {
        // I do the propper checking of the param here, and return the result
    }


    public IObject CreateInstance(parametar param)
    {
        return new Object1(param);
    }
} 
  • 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-27T16:07:01+00:00Added an answer on May 27, 2026 at 4:07 pm

    This is your problem, in Object1:

    public parametar param { get { return this.param; } set { this.param = value; }
    

    That property calls itself recursively – which is exactly why you’re getting a stack overflow. Don’t do that. Instead, you probably either want an automatically-implemented property:

    public parameter param { get; set; }
    

    or use a private backing field:

    private parametar param;
    public parametar Param { get { return param; } set { param = value; }
    

    Additionally, I’d strongly recommend that you start following .NET naming conventions, and pay attention to spelling in type and member names.

    So you probably want your class to be called Parameter – although personally I’d at least try to make it a little bit more descriptive, e.g. QueryParameter or something similar. Likewise Object1 isn’t exactly a semantically-meaningful name – I hope it’s not the name in your real code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a class, Plotter , which has a static event (declared public static
I have the following class class CItem { public: CItem(CRegistry &Registry) _Registry(Registry) {Registry.Register();} ~CItem()
I have this code to register dlls into my gac Assembly asm = Assembly.LoadFrom(argument);
I have this function: RegisterGlobalHotKey(Keys.F6, MOD_SHIFT | MOD_CONTROL); which call an API to register
I have this code in jQuery, that I want to reimplement with the prototype
I have this idea for a free backup application. The largest problem I need
I have this RewriteRule that works too well :-) RewriteRule ^([^/]*)/$ /script.html?id=$1 [L] The
I have a bank/collection which caches instances of objects in memory so that each
I have a class that I wish to expose as a remote service using
I need to code a class that recieves a collection with any number of

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.