title: How to fix 'System.StackOverflowException?
body: <p>I have a project programmed in <strong>C#</strong> <strong>NET 3.5</strong> in <strong>WPF</strong> which start very well in debug. However for example, in my <code>TemplateColor.cs</code> class I have this:</p>
  
  <pre><code>using System;
  using System.Windows.Media;
  
  namespace EWIN_THEME_MAKER.ThemeMaker
  {
      public class TemplateColor
      {
          private int _id;
  
          private string _name;
  
          private string _toneName;
  
          public int ID
          {
              get
              {
                  return this._id;
              }
              set
              {
                  this._id = value;
              }
          }
  
          public int AllVerticalPos
          {
              get;
              set;
          }
  
          public int AllHorizontalPos
          {
              get;
              set;
          }
  
          public int HuePageNum
          {
              get;
              set;
          }
  
          public int HuePos
          {
              get;
              set;
          }
  
          public int TonePaneNum
          {
              get;
              set;
          }
  
          public int TonePos
          {
              get;
              set;
          }
  
          public string Name
          {
              get
              {
                  return this._name;
              }
              set
              {
                  this._name = value;
                  string[] array = this._name.Split(new char[]
                  {
                      '_'
                  });
                  this._toneName = array[0];
                  if (array.Length &gt; 1)
                  {
                      this.HuePageNum = int.Parse(array[1]);
                  }
              }
          }
  
          public string ToneName
          {
              get
              {
                  return this._toneName;
              }
              set
              {
                  this._toneName = value;
              }
          }
  
          public Color DarkColor
          {
              get;
              set;
          }
  
          public Color MainColor
          {
              get;
              set;
          }
  
          public Color LightColor
          {
              get;
              set;
          }
  
          public Color ShadowColor
          {
              get;
              set;
          }
  
          public byte ShadowA
          {
              get;
              set;
          }
  
          public Color GrowColor
          {
              get;
              set;
          }
  
          public Color TextShadowColor
          {
              get;
              set;
          }
  
          public Color TextMainColor
          {
              get;
              set;
          }
  
          public Color TextSelectColor
          {
              get;
              set;
          }
  
          public double TextShadowPosition
          {
              get;
              set;
          }
  
          public Brush DarkColorBrush
          {
              get
              {
                  return new SolidColorBrush(this.DarkColor);
              }
          }
  
          public Brush MainColorBrush
          {
              get
              {
                  return new SolidColorBrush(this.MainColor);
              }
          }
  
          public Brush LightColorBrush
          {
              get
              {
                  return new SolidColorBrush(this.LightColor);
              }
          }
  
          public Brush ShadowColorBrush
          {
              get
              {
                  return new SolidColorBrush(this.ShadowColor);
              }
          }
  
          public Brush GrowColorBrush
          {
              get
              {
                  return new SolidColorBrush(this.GrowColor);
              }
          }
  
          public Brush TextShadowColorBrush
          {
              get
              {
                  return new SolidColorBrush(this.TextShadowColor);
              }
          }
  
          public Brush TextMainColorBrush
          {
              get
              {
                  return new SolidColorBrush(this.TextMainColor);
              }
          }
  
          public Brush TextSelectColorBrush
          {
              get
              {
                  return new SolidColorBrush(this.TextSelectColor);
              }
          }
  
          public TemplateColor()
          {
              this.ID = -1;
              this.AllVerticalPos = -1;
              this.AllHorizontalPos = -1;
              this.HuePageNum = -1;
              this.HuePos = -1;
              this.TonePaneNum = -1;
              this.TonePos = -1;
              this.Name = "---";
              this.DarkColor = default(Color);
              this.MainColor = default(Color);
              this.LightColor = default(Color);
              this.ShadowColor = default(Color);
              this.ShadowA = 0;
              this.GrowColor = default(Color);
              this.TextShadowColor = default(Color);
              this.TextMainColor = default(Color);
              this.TextSelectColor = default(Color);
              this.TextShadowPosition = 0.0;
          }
      }
  }
  </code></pre>
  
  <p>In this code, there are multiple errors of this kind:</p>
  
  <blockquote>
    <p>An exception of type 'System.StackOverflowException</p>
  </blockquote>
  
  <p>For example I take this part of the code there:</p>
  
  <pre><code>public string Name
  {
      get
      {
          return this._name;
      }
      set
      {
          this._name = value;
          string[] array = this._name.Split(new char[]
          {
              '_'
          });
          this._toneName = array[0];
          if (array.Length &gt; 1)
          {
              this.HuePageNum = int.Parse(array[1]);
          }
      }
  }
  </code></pre>
  
  <p>So, in the next lines of this code there is an infinite call? I do not know how to correct this error.</p>
  
  <pre><code>string[] array = this._name.Split(new char[]
  </code></pre>
  
  <p>And...</p>
  
  <pre><code>this.HuePageNum = int.Parse(array[1]);
  </code></pre>
  
  <p>How do we predict and correct these errors?
  <a href="https://i.stack.imgur.com/DdIRv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DdIRv.png" alt="Yes"></a></p>