c# - Exception on Auto Properties


my application throwing stack overflow exceptions on startup on auto properties , objects creation.

they working without problems, have not modified them.

basically have abstract class "rule" implements interface "irule", properties interface. have child class inherits rule, exception on child class.

edit:

public class rulea: rule {     private rulea_bestsettings;      #region properties      public override rule bestsettings { { return _bestsettings; } set { _bestsettings = value rulea; } }       #endregion      public rulea()     {         initialize();     }      protected override void initialize()     {         base.initialize();          _bestsettings = new rulea();     }    } 

}

now i'm getting exception on initialize method when instantiate property

this happens when new object properties instanciated.

si รจ verificata l'eccezione system.stackoverflowexception   hresult=0x800703e9   messaggio=generata eccezione di tipo 'system.stackoverflowexception'. 

i can't figure out, ideas? thanks!

in initialize section, instantiating new rulea. new rulea construct , in doing call own initialize section , create third rulea. create fourth. , fifth. , on, until stack fills up.

i not sure trying accomplish, guess instead of this

protected override void initialize() {     base.initialize();      _bestsettings = new rulea(); } 

you meant this:

protected override void initialize() {     base.initialize();      _bestsettings = this;  } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -