Get Random Strings from a List Array in Unity C#

Get Random Strings from a List Array in Unity C#

    public List<string> myListOfStrings; // Declering Lists of strings

    public List<string> newListOfRandomStrings;

    public int numberOfRandomPicks = 4;




    // Start is called before the first frame update
    void Start()
    {
        myListOfStrings.Add("String_1");
        myListOfStrings.Add("String_2");
        myListOfStrings.Add("String_3");
        myListOfStrings.Add("String_4");
        myListOfStrings.Add("String_5");
        myListOfStrings.Add("String_6");
        myListOfStrings.Add("String_7");
        myListOfStrings.Add("String_8");
        myListOfStrings.Add("String_9");
        myListOfStrings.Add("String_10");

        PickRandomStringsFromAList();
    }



    public void PickRandomStringsFromAList()
    {
        int indexOfRandomWord;

        string wordFromList;

        for (int i = 0; i < numberOfRandomPicks; i++)
        {
            indexOfRandomWord = Random.Range(0, myListOfStrings.Count);

            wordFromList = myListOfStrings[indexOfRandomWord];

            Debug.Log(wordFromList);

            newListOfRandomStrings.Add(wordFromList);
        }
    }