C# The requested operation caused a stack overflow. BaseWeapon.set_metalWeaponType (MetalWeaponTypes value) (at Assets/Scripts/New Folder/BaseWeapon.cs:23)

So i have gotten this error I dont know why but i need help. I was Making a Rpg and this is used to create the weapon Im giving all code associated with it
Used to get stats for the weapon (Name, Desc, And rgp stats)

using UnityEngine;
using System.Collections;

public class BaseCC {

    private string charClassname;
    private string charClassDesc;

    private int staminia;
    private int endurance;
    private int strenght;
    private int intellagnce;

    public string CharClassName {
        get { return charClassname; }
        set { charClassname = value; }

    }
    public string CharClassDesc {
    
            get { return charClassDesc; }

            set { charClassDesc = value; }
        }



    public int Staminia {
        get { return staminia; }
        set { staminia = value; }
    }

    public int Endurance {
        get { return endurance; }
        set { endurance = value; }
    }

    public int Strenght {
        get { return strenght; }
        set { strenght = value; }
    }

    public int Intellagnce {
        get { return intellagnce; }
        set { intellagnce = value; }
    }

}

main choser for item

using UnityEngine;
using System.Collections;

public class BaseItem
{

    private string itmName;
    private string itmDesc;
    private int itmID;
    public enum ItmTypes
    {
        EQUIPMENT,
        WEAPON,
        SCROLL,
        POTION

    }
    private ItmTypes itmType;

    public string ItmName
    {
        get { return itmName; }
        set { itmName = value; }
    }
    public string ItmDesc
    {
        get { return itmDesc; }
        set { itmDesc = value; }
    }
    public int ImtID
    {
        get { return itmID; }
        set { itmID = value; }
    }
    public ItmTypes itemType
    {
        get { return itemType; }
        set { itemType = value; }
    }
}

Used to get stats on weapon

using UnityEngine;
using System.Collections;

public class BaseItmStat : BaseItem{

    private int staminia;
    private int endurance;
    private int strenght;
    private int intellagnce;

    public int Staminia
    {
        get { return staminia; }
        set { staminia = value; }
    }

    public int Endurance
    {
        get { return endurance; }
        set { endurance = value; }
    }

    public int Strenght
    {
        get { return strenght; }
        set { strenght = value; }
    }

    public int Intellagnce
    {
        get { return intellagnce; }
        set { intellagnce = value; }
    }
}

Used for Weapon Types
using UnityEngine;
using System.Collections;

public class BaseWeapon : BaseItmStat
{
    public enum MetalWeaponTypes
    {
        SWORD,
        DAGGER,
        BATTLEAXE,
        WARHAMMER,
        LONGSWORD,
        MACE,
        CLAW

    }
    

    private int spellEffectID;
    public MetalWeaponTypes metalWeaponType
    {
        get { return metalWeaponType; }
        set { metalWeaponType = value; }
    }

    public int SpellEffectID
    {
        get { return spellEffectID; }
        set { spellEffectID = value; }
    }

/*    public enum RangedWeaponTypes
        {
            BOW,
            ARROW,
            CROSSBOW,
            BOLT,
            SLING,
            SHURIKEN


        }
        public RangedWeaponTypes rangedWeaponType
        {
            get { return rangedWeaponType; }
            set { rangedWeaponType = value; }
        }
    */
}

Used to Make Weapon

using UnityEngine;
using System.Collections;

public class CreateNewWep : MonoBehaviour
{
    private BaseWeapon newWeapon;

    void Start() {
        CreateWeapon();
        Debug.Log(newWeapon.ItmName);
        Debug.Log(newWeapon.ItmDesc);
        Debug.Log(newWeapon.ImtID.ToString());
        Debug.Log(newWeapon.metalWeaponType.ToString());
        Debug.Log(newWeapon.Endurance.ToString());
        Debug.Log(newWeapon.Staminia.ToString());
        Debug.Log(newWeapon.Intellagnce.ToString());
        Debug.Log(newWeapon.Strenght.ToString());
    }

    public void CreateWeapon() {
        //Assign Name
        newWeapon = new BaseWeapon();
        newWeapon.ItmName = "W" + Random.Range(1, 101);
        //Create Description
        newWeapon.ItmDesc = "This Is a New Weapon.";
        //Create WeapID
        newWeapon.ImtID = Random.Range(1, 101);
        //Apply Stats
        newWeapon.Endurance = Random.Range(1, 50);
        newWeapon.Staminia = Random.Range(1, 50);
        newWeapon.Intellagnce  = Random.Range(1, 50);
        newWeapon.Strenght = Random.Range(1, 50);
        //Apply Type
        ChoseWeaponType();
        //Sets Effect ID
       newWeapon.SpellEffectID = Random.Range(1, 101);
    }
    private void ChoseWeaponType() {
        int randomTemp = Random.Range(1, 7);
        if (randomTemp == 1)
        {
            newWeapon.metalWeaponType = BaseWeapon.MetalWeaponTypes.SWORD;
        }
        else if (randomTemp == 2)
        {
            newWeapon.metalWeaponType = BaseWeapon.MetalWeaponTypes.DAGGER;
        }
        else if (randomTemp == 3)
        {
            newWeapon.metalWeaponType = BaseWeapon.MetalWeaponTypes.BATTLEAXE;
        }
        else if (randomTemp == 4)
        {
            newWeapon.metalWeaponType = BaseWeapon.MetalWeaponTypes.WARHAMMER;
        }
        else if (randomTemp == 5)
        {
            newWeapon.metalWeaponType = BaseWeapon.MetalWeaponTypes.LONGSWORD;
        }
        else if (randomTemp == 6)
        {
            newWeapon.metalWeaponType = BaseWeapon.MetalWeaponTypes.MACE;
        }
        else if (randomTemp == 7)
        {
            newWeapon.metalWeaponType = BaseWeapon.MetalWeaponTypes.CLAW;
        }
      /*   else if (randomTemp == 8)
        {
            newWeapon.rangedWeaponType = BaseWeapon.RangedWeaponTypes.BOW;
        }
       else if (randomTemp == 9)
        {
            newWeapon.rangedWeaponType = BaseWeapon.RangedWeaponTypes.ARROW;
        }
        else if (randomTemp == 10)
        {
            newWeapon.rangedWeaponType = BaseWeapon.RangedWeaponTypes.CROSSBOW;
        }
        else if (randomTemp == 11)
        {
            newWeapon.rangedWeaponType = BaseWeapon.RangedWeaponTypes.BOLT;
        }
        else if (randomTemp == 12)
        {
            newWeapon.rangedWeaponType = BaseWeapon.RangedWeaponTypes.SLING;
        }
        else if (randomTemp == 13)
        {
            newWeapon.rangedWeaponType = BaseWeapon.RangedWeaponTypes.SHURIKEN;
        }
*/
    }
}

public ItmTypes itemType
{
get { return itemType; }
set { itemType = value; }
}

There’s your problem. Your getter is returning the property, which calls the getter, which returns the property, which calls the getter… and so on. I’m guessing you want this:

public ItmTypes itemType
 {
     get { return itmType; }
     set { itmType = value; }
 }

You can write all of this in an easier way:

public ItmTypes itemType 
{ 
    get; 
    set;
}

If you know you’re going to eventually add other logic to the getter and setter locations, then keep what you have currently for those properties, but otherwise the automatically generated get/set created by doing it this way is sufficient.

Thank you @jdean300 but i tried that and im still geting the error in BaseWeapon.Cs