How to get my `collider2D.cast` work?

When I encountered this API : collider.cast(), I fell in love with it. It perfectly suits my need. However, I cannot detect any collision using the code below, and surprisingly, I haven’t any demo code to my problem. Please help.

// all gameObjects have collider2D, and rigidbody2D, and are on the same layer.
// a circle is on the left side of a rectangle and is going to collide with the rectangle.

void Update()
{
    myCollider.Cast( Vector2.right, hitResults);
    if( hitResults != null)
    {
        //print all the collider info
    }

}

The length of RaycastHit2D hitRetults must be greater than 0 before use Collider2D.Cast.
I hope it helps you!

        void Update()
        {
            int maxResultCount = 10;
            var hitResults = new RaycastHit2D[maxResultCount] 
            myCollider.Cast(Vector2.right, hitResults);
            if (hitResults[0] == true)
            {
                //print all the collider info
            }

        }