Two C# questions; how can I reinterpret cast a float to an int? Does C# have a non-static conversion operator or user-defined assignment operator so that the conversion takes place on 'this'?
<p>1.
How can I reinterpret cast a float to a int (or a double to a long)?</p>

<pre><code>float f = 2.0f;
int i = (int)f; // causes conversion
</code></pre>

<p>I only want to copy the bit-pattern from f to i. How can this be done?</p>

<p>2.
The implicit and explicit operators in C# uses one intermediate object because the operator function is 'static'</p>

<pre><code>public static implicit operator MyClass(double s)
{
    return new MyClass(s);
} 
..
..
MyClass m = 2.2; // this code uses 'm' and one intermediate object.
</code></pre>

<p>This is fine for reference types, but for value-types which are big (say 20-30 bytes), this will cause unnecessary data copy. Is my understanding correct? And If yes, then why doesn't C# have a non-static conversion operator or user-defined assignment operator so that the conversion/assignment takes place on 'this'? If it does, whats the way to do it?</p>

<p>Thanks</p>
