Operator overloading, structs and boxing

A

Andrew Larder

Hi,

I'm trying to write a high performance numerical app in C#, and would like
to use operator overloading, but currently things are running a bit slower
than non op-overloaded code.

If I overload operators on a struct, lets for example say a Vector3 (3D
vector), does this mean when I write:

Vector3 a = new Vector(1,2,3);
Vector3 b = new Vector(4,5,6);
Vector3 c = new Vector(0,0,0);
c = a + b;

that 'a' and 'b' have to be boxed before they are passed to my
operator+(...) code, and the return value boxed as well?
 
G

Guest

Hi. Why don’t you check the MSIL code? That way you can easily see if they are boxed or not.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top