Look at $d+1$, the largest number of affinely independent points from $C$. Let $x_0$, $\ldots$, $x_d$ one such affinely independent subset of largest size. Note that every other point is an affine combination of the points $x_k$, so lies in the affine subspace generated by them, which is of dimension $d$.
If $d < n$ then this subspace is contained in an affine hyperplane.
If $d=n$, then $C$ contains $d+1$ affinely independent points. Since $C$ is convex, it will also contain the convex hull of those $n+1$ points. Now, in an $n$-dimensional space the convex hull of $n+1$ affinely independent points has non-empty interior. So the interior of $C$ is non-empty.
I will prove the case where $x_0 = 0$, since convexity is invariant under translation.
According to the definition, your ray is of the form, for a fixed $\mathbf{x} \in \mathbb{R}^d$,
$$R= \{\lambda\mathbf{x} : \lambda \geqslant 0\}$$
Now let $\mathbf{y},\mathbf{z} \in R$, so $\mathbf{y} = y\mathbf{x}$ and $\mathbf{z} = z\mathbf{x}$ for some $y,z\geqslant 0$ by definition of the ray. As this is a subset of a $2$-dimensional linear (affine, if $x_0 \neq 0$) subspace, all convex combinations will require at most two terms without any redundancy (it is not hard to show for many-termed sums, I will leave this as an exercise to help understand the proof). So for all $t \in [0,1]$, it suffices to show:
$$t\mathbf{y} + (1-t)\mathbf{z} \in R$$
The terms $t\mathbf{y}, (1-t)\mathbf{z}$ are the same as $ty\mathbf{x}$ and $(1-t)z\mathbf{x}$ by the result above, and as $t$ and $(1-t)$ are both at least $0$, $t\mathbf{y}$ and $(1-t)\mathbf{z}$ are in the ray. As such, the above sum is just:
$$(ty + (1-t)z)\mathbf{x}$$
which is in the ray, so the ray is convex.
Generally, proving shapes convex involve showing the conditional:
$$\{\mathbf{x}\}_i \in X \Longrightarrow \sum_i \lambda_i \mathbf{x}_i \in X$$
for $\sum \lambda_i =1$ and each $\lambda_i \geqslant 0$, holds true. You can see how the above proof is essentially just this conditional.
Geometrically and intuitively, a shape is convex when the line between any two points is in the shape. I dare you to find two points in a ray where the line between them is not in the ray.
Best Answer
This is probably in the context of a constrained optimization problem "minimize $f$ within convex set $X$." In constrained optimization, the gradient need not be zero at the optimizer (specifically, when the optimizer is not in the interior of $X$). The optimality condition is "$\nabla f(x)^\top (y-x) \ge 0$ for all $y \in X$."
When $X$ is the entire space, then this result generalizes to the "gradient equals zero" condition for unconstrained optimization, since the vector $y-x$ can point in any direction.