title: How to randomly pick value from a list in Unity3D?
body: <p>Suppose I have a list of Robot class [List&lt; Robot> myList=new List&lt; Robot>()]. Each Robot has a name and id depending on its colour. Now randomly pick values from the list and give an output of how many Robots of each colour are there on your list.
  (N.B. Consider you have only 3 colored Robot[Yellow,green, red])</p>
  
  <p>my code:</p>
  
  <pre><code>public class Test : MonoBehaviour
  {
      private void Start()
      {
          List&lt;Robot&gt; myList = new List&lt;Robot&gt;();
          List&lt;string&gt; robotList = new List&lt;string&gt;();
          robotList.Add("yellow");
          robotList.Add("green");
          robotList.Add("red");
  
          int someNum = Random.Range(0, robotList.Count);
          string robotNumber = robotList[someNum];
          robotList.RemoveAt(someNum);
          Robot robot;
          int id = 0;
          robot = new Robot(robotNumber, id);
          Debug.Log(robot);
          id++;
      }
  }
  
  public class Robot
  {
      public string name;
      public int id;
      public Robot(string name, int id)
      {
          this.name = name;
          this.id = id;
      }
  }
  </code></pre>
  
  <p>but this not work maybe.. actually I don't understand what actually my output is...</p>