Can this code be simplified. I have a lot of repeating lines. I'm a Beginner

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class TowerSpawner : MonoBehaviour //, IDeselectHandler
{
[SerializeField] Transform tSpawnPoint;
[SerializeField] GameObject towerA;
[SerializeField] GameObject towerB;
[SerializeField] GameObject towerC;
[SerializeField] GameObject towerD;
[SerializeField] GameObject towerA_Upgrade1;
[SerializeField] GameObject towerB_Upgrade1;
[SerializeField] GameObject towerC_Upgrade1;
[SerializeField] GameObject towerD_Upgrade1;
[SerializeField] Sprite confirmationSprite;

Sprite selectedButtonSprite;
Button selectedButton;

GameObject selectedObject;
bool towerPlaced; public bool TowerPlaced { get { return towerPlaced; } }
bool towerUpgraded; public bool TowerUpgraded { get { return towerUpgraded; } }

TowerSpawnPoint tSPoint; // reference to the TowerSpawner script

private void Start()
{
    tSPoint = FindObjectOfType<TowerSpawnPoint>();
    towerPlaced = false;
}

public void SelectedTowerA ()
{
    selectedObject = towerA;
    EnterConfirmationStage();
}
public void SelectedTowerB()
{
    selectedObject = towerB;
    EnterConfirmationStage();
}
public void SelectedTowerC()
{
    selectedObject = towerC;
    EnterConfirmationStage();
}
public void SelectedTowerD()
{
    selectedObject = towerD;
    EnterConfirmationStage();
}

public void SpawnTowerNormal( )
{
    Instantiate(selectedObject, tSpawnPoint.position, Quaternion.identity);
    if (towerUpgraded)
    {
        PostUpgradeSequence();
        //return;
    }

    PostTowerPlacementSequence();
}

void PostTowerPlacementSequence()
{
    towerPlaced = true;
    tSPoint.ShowBuildMenu(false);
}

void PostUpgradeSequence()
{
    //towerUpgraded = true;
    tSPoint.ShowUpgradeMenu(false);
}

void EnterConfirmationStage ()
{
    selectedButton = EventSystem.current.currentSelectedGameObject.GetComponent<Button>();
    selectedButton.GetComponent<Image>().sprite = confirmationSprite;
    selectedButtonSprite = selectedButton.GetComponent<Image>().sprite;
    selectedButton.onClick.AddListener(SpawnTowerNormal);

}

public void UpgradeTowerButton()
{
    if (tSPoint.CurrentSelectedTower.name == "TowerA(Clone)")
    {
        selectedObject = towerA_Upgrade1;
        towerUpgraded = true;
        EnterConfirmationStage();
    }

    if (tSPoint.CurrentSelectedTower.name == "TowerB(Clone)")
    {
        selectedObject = towerB_Upgrade1;
        towerUpgraded = true;
        EnterConfirmationStage();
    }

    if (tSPoint.CurrentSelectedTower.name == "TowerC(Clone)")
    {
        selectedObject = towerC_Upgrade1;
        towerUpgraded = true;
        EnterConfirmationStage();
    }

    if (tSPoint.CurrentSelectedTower.name == "TowerD(Clone)")
    {
        selectedObject = towerD_Upgrade1;
        towerUpgraded = true;
        EnterConfirmationStage();
    }
}

public void SellTower()
{
    //GameObject objectToDestroy;

    //objectToDestroy = FindObjectOfType<Tower>();

    towerPlaced = false;
    towerUpgraded = false;
}

}

There are various ways to do this, but if your new to coding here is a simple way to may be more intuitive to you:

using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class TowerSpawner : MonoBehaviour
{
    [SerializeField] Transform tSpawnPoint;
    [SerializeField] GameObject towerA;
    [SerializeField] GameObject towerB;
    [SerializeField] GameObject towerC;
    [SerializeField] GameObject towerD;
    [SerializeField] GameObject towerA_Upgrade1;
    [SerializeField] GameObject towerB_Upgrade1;
    [SerializeField] GameObject towerC_Upgrade1;
    [SerializeField] GameObject towerD_Upgrade1;
    [SerializeField] Sprite confirmationSprite;

    Dictionary<string, GameObject> towerTypes = new Dictionary<string, GameObject>();
    Dictionary<string, GameObject> towerUpgrades = new Dictionary<string, GameObject>();

    Sprite selectedButtonSprite;
    Button selectedButton;
    GameObject selectedObject;
    bool towerPlaced;
    public bool TowerPlaced { get { return towerPlaced; } }
    bool towerUpgraded;
    public bool TowerUpgraded { get { return towerUpgraded; } }
    TowerSpawnPoint tSPoint; // reference to the TowerSpawner script

    private void Start()
    {
        tSPoint = FindObjectOfType<TowerSpawnPoint>();
        towerPlaced = false;

        towerTypes.Add("TowerA", towerA);
        towerTypes.Add("TowerB", towerB);
        towerTypes.Add("TowerC", towerC);
        towerTypes.Add("TowerD", towerD);

        towerUpgrades.Add("TowerA(Clone)", towerA_Upgrade1);
        towerUpgrades.Add("TowerB(Clone)", towerB_Upgrade1);
        towerUpgrades.Add("TowerC(Clone)", towerC_Upgrade1);
        towerUpgrades.Add("TowerD(Clone)", towerD_Upgrade1);
    }

    public void SelectTower(string towerType)
    {
        selectedObject = towerTypes[towerType];
        EnterConfirmationStage();
    }

    public void SpawnTowerNormal()
    {
        Instantiate(selectedObject, tSpawnPoint.position, Quaternion.identity);
        if (towerUpgraded)
        {
            PostUpgradeSequence();
        }
        else
        {
            PostTowerPlacementSequence();
        }
    }

    void PostTowerPlacementSequence()
    {
        towerPlaced = true;
        tSPoint.ShowBuildMenu(false);
    }

    void PostUpgradeSequence()
    {
        tSPoint.ShowUpgradeMenu(false);
    }

    void EnterConfirmationStage()
    {
        selectedButton = EventSystem.current.currentSelectedGameObject.GetComponent<Button>();
        selectedButton.GetComponent<Image>().sprite = confirmationSprite;
        selectedButtonSprite = selectedButton.GetComponent<Image>().sprite;
        selectedButton.onClick.AddListener(SpawnTowerNormal);
    }

    public void UpgradeTowerButton()
    {
        string currentTowerName = tSPoint.CurrentSelectedTower.name;

        if (towerUpgrades.ContainsKey(currentTowerName))
        {
            selectedObject = towerUpgrades[currentTowerName];
            towerUpgraded = true;
            EnterConfirmationStage();
        }
    }

    public void SellTower()
    {
        towerPlaced = false;
        towerUpgraded = false;
    }
}

Now, you can call the SelectTower() method with a string parameter representing the tower type, like “TowerA”, “TowerB”, etc to select a tower. The towerTypes and towerUpgrades dictionaries help eliminate repetitive code and make it easier to add more tower types and upgrades in the future.

Again there are numerous other ways you could simplify it further but I think this may be an intuitive way you can study to see how to use dictionaries.