Transition from a Riemann sum to an Integral The Riemann sum over an interval $[a,b]$ is usually defined as
$$\lim\limits_{N\to\infty}\sum\limits_{k=0}^Nf\left(a+k\cdot\frac{b-a}{N}\right)\frac{b-a}{N}$$
Thus if we encounter a sum of the form
$$\lim\limits_{N\to\infty}\sum\limits_{k=0}^Nf\left(k\cdot\frac{1}{N}\right)\frac{1}{N}$$
we can conclude that it is equal to an integral over the interval $[0,1]$.
$$\lim\limits_{N\to\infty}\sum\limits_{k=0}^Nf\left(k\cdot\frac{1}{N}\right)\frac{1}{N}=\int_0^1f(x)dx\tag{1}\label{1}$$
What can we conclude about the following sum
$$\lim\limits_{N\to\infty}\lim\limits_{M\to\infty}\sum\limits_{k=0}^M f\left(k\cdot\frac{1}{N}\right)\frac{1}{N}\tag{2}\label{2}$$
To clarify, this is an infinite sum \eqref{2}, that differs from the Riemann sum \eqref{1}, in the upper limit of the sum. In the Riemann sum \eqref{1}, there is a relation between $M$ and $N$, namely $N=M$, while there is no such relation specified in \eqref{2}. If we can equate it to an integral, how are we to determine the limits of integration?
The equation \eqref{2} is to be taken, that the $M\to\infty$, we thus have an infinite sum (suppose it is convergent). Than we form a sequence of infinite sums, where $N$ increases for each element of the sequence. That is
$$S_N=\lim\limits_{M\to\infty}\sum\limits_{k=0}^M f\left(k\cdot\frac{1}{N}\right)\frac{1}{N}$$
What does this sequence tend to?
Is it true that (or when is it true)
$$\lim\limits_{N\to\infty}S_N=\int_0^\infty f(x)dx$$
Also the general term in \eqref{2} is $C_k=f\left(k\cdot\frac{1}{N}\right)$. How does it behave in the limit, namely
$$\lim\limits_{N\to \infty}\lim\limits_{M\to \infty}f\left(M\cdot\frac{1}{N}\right)$$
 A: Suppose $f$ is Riemann integrable on $[0,b]$ for every $b > 0$ and the improper integral over $[0, \infty)$ is convergent.
We first consider the case where $f$ is nonnegative and non-increasing, as suggested by @Winther, where we have 
$$\frac{f((k+1)/N)}{N} \leqslant \int_{k/N}^{(k+1)/N} f(x) \, dx \leqslant \frac{f(k/N)}{N}. $$
This implies
$$\int_0^{(M+1)/N} f(x) \, dx \leqslant \frac{1}{N} \sum_{k=0}^{M} f(k/N) \leqslant \frac{f(0)}{N} + \int_0^{M/N} f(x) \, dx. $$
The sequence of partial sums is increasing and bounded , hence convergent as $M \to \infty$, with
$$\int_0^{\infty} f(x) \, dx \leqslant\frac{1}{N} \sum_{k=0}^{\infty} f(k/N) \leqslant \frac{f(0)}{N} + \int_0^{\infty} f(x) \, dx. $$
Therefore,
$$\lim_{N \to \infty} \lim_{ M \to \infty}\frac{1}{N} \sum_{k=0}^{M} f(k/N) = \int_0^\infty f(x) \, dx.$$
Can this still hold if $f$ is not monotonic? 
For example, consider $f(x) = \sin x /x$, where
$$\int_0^\infty \frac{\sin x}{x} \, dx = \frac{\pi}{2}.$$
Examining the corresponding series (WLOG starting with $k=1$) we find
$$\frac{1}{N}\sum_{k = 1}^{\infty} \frac{\sin (k/N)}{k/N} = \sum_{k = 1}^{\infty} \frac{\sin (k/N)}{k} \\ = \frac{\pi}{2}-\frac{1}{2N} \\ \longrightarrow_{N \to \infty} \frac{\pi}{2}.$$
I have not yet found a counterexample for a non-monotone function. As the integral test can be generalized to $C^1$ functions of bounded variation, I suspect this may characterize a wider class of functions for which this result holds.
This could be shown by considering
$$\left|\int_{k/N}^{(k+1)/N} f(x) \, dx - \frac{f(k/N)}{N} \right|  \leqslant \int_{k/N}^{(k+1)/N} |f(x) - f(k/N)| \, dx $$
and then summing over $k$, applying the mean value theorem when $f$ is differentiable, and using $\int_0^\infty |f'(x)|\, dx < \infty$  to show that the sum converges to the integral as $N \to \infty.$
