How to apply an algorithm for a C# container like functor in C++?
<p>In C++ to apply an algorithm for a collection or container, I overload the <code>operator()</code>. For example generate random number for a container:  </p>

<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;
#include &lt;algorithm&gt;
#include &lt;cstdlib&gt;

using namespace std;

class rnd_gen {
public:
    rnd_gen( int lo, int up ) : lo( lo ), up( up ) {

    }

    int operator()() const {
        return lo + rand() % up;
    }

private:
    int lo;
    int up;
};

int main() {
    vector&lt;int&gt; vt;
    vt.push_back( 3 );
    vt.push_back( 1 );
    vt.push_back( 2 );
    generate( vt.begin(), vt.end(), rnd_gen( 10, 100 ) );
}
</code></pre>

<p>Is is possible to perform these kinds of operation without explicitly writing a for loop? Or any closest equivalent approach in C#.</p>

<p>Thanks,<br>
Chan </p>
