how to set a public GameObject when button clicked

bassically i have a button and when its clicked i want to find the name of the button and set the Selectedobject variable, but im not sure how to approach this

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class setSeletedObject : MonoBehaviour {

    public string SelectedObject:

	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
		
	}

   SetSelectedObject();{
        SelectedObject = ;
    }
}

You could have SetSelectedObject take a string argument, and then set the Button’s onClick function to pass the string you want. Its not a super robust way of doing this but it would work.

A minor build on this would be to have SetSelectedObject take a GameObject argument and just reference its name in the function. This way if you change the button’s name, you don’t have to change it in both places.

is it possible that i could get an example of the code

@pslattery