"Sack" data structure in C# The idea is to have a data structure that holds any number of objects of any type. Objects can be retrieved, or removed permanently, at random. Also, it can be cleared (or emptied).

This class just provides the ability to select a random object from a collection, with the option of removing it.

public class Sack
{
    private List&lt;object&gt; objects;

    public Sack()
    {
        objects = new List&lt;object&gt;();
    }

    public void Add&lt;T&gt;(T obj)
    {
        objects.Add(obj);
    }

    public object Retrieve()
    {
        int numberObjects = objects.Count;

        Random rand = new Random();
        int selectedIndex = rand.Next(0, numberObjects);

        return objects[selectedIndex];
    }

    public object Remove()
    {
        int numberObjects = objects.Count;

        Random rand = new Random();
        int selectedIndex = rand.Next(0, numberObjects);

        object selectedObject = objects[selectedIndex];
        objects.RemoveAt(selectedIndex);

        return selectedObject;
    }

    public void Empty()
    {
        objects.Clear();
    }
}
You don't use any method which is specific to List&lt;T&gt;. You should always code against interfaces if possible, meaning you should use IList&lt;T&gt; instead of List&lt;T&gt;.  
If Retrieved is called very often in a short time it is likely that you get the same object each time. This is because Random when instantiated will use the system clock to provide a seed value. You should have one Random object as a class-level field which should be instantiated in the constructor or directly.  
The genericness of the method Add&lt;T&gt; doesn't buy you anything. A simple Add(object) would be enough and does the exact same.  
objects should be made readonly because you don't change it.  
For Retrieve and Remove I wouldn't introduce the numberObjects variable but if you want to keep it you should rename it to e.g numberOfObjects.  


Implementing the mentioned points would look like this:  

public class Sack
{
    private readonly IList&lt;object&gt; objects = new List&lt;object&gt;();
    private readonly Random rand = new Random();

    public void Add(object obj)
    {
        objects.Add(obj);
    }

    public object Retrieve()
    {
        int selectedIndex = rand.Next(0, objects.Count);

        return objects[selectedIndex];
    }

    public object Remove()
    {
        int selectedIndex = rand.Next(0, objects.Count);

        object selectedObject = objects[selectedIndex];
        objects.RemoveAt(selectedIndex);

        return selectedObject;
    }

    public void Empty()
    {
        objects.Clear();
    }
}