how to randomly choose color unity code example

Example 1: unity random color

// Pick a random, saturated and not-too-dark color
GetComponent<Renderer>().material.color = Random.ColorHSV(0f, 1f, 1f, 1f, 0.5f, 1f);

Example 2: set object to random color unity

[RequireComponent(typeof(Renderer))]
public class colorTint : MonoBehaviour
{
    public List<Color> TintColors;
    // Start is called before the first frame update
    void Start()
    {

            Color c = TintColors[Random.Range(0, TintColors.Count)];

            GetComponent<Renderer>().material.color = c;
    }