"Carl" <Ca**@discussions.microsoft.com> wrote in
news:67**********************************@microsof t.com...
I do a project using C# and C++ .NET and have some functionality to
convert
imperial to metric units and vice versa.
In VC6 I just used a simple header file with some constants (e.g. const
double MM_TO_INCH = 1.0/25.4;).
For .NET I thought it might be a good idea to have a class with static
methods for that to use in C# as well as C++ code.
C# didn't work well for that because I could not overload methods if they
only differ in types.
Do you mean differ in return types?
That applies to C++ as well.
So I did the implementation in a C++ class called Units (e.g. static
Double
MMtoINCH (Double MM) { return MM/(Double)25.4; } for the basic float
types.
Doing e.g. this:
static double MMtoINCH (double MM) { return MM/(double)25.4; }
static float MMtoINCH (float MM) { return MM/(float)25.4; }
In C# works fine.
Post a sample if you need help on that topic.
It works, but my concern is about the performance.
With VC6 the compiler would easily replace the function call by inlining
the
code.
So does the JIT. (in a release build)
With .NET I have the IL code in an assembly which needs to be loaded and
then compiled by the JIT.
Does anyone know how good the JIT compiler handles this issue? Is he able
to
do the same kind of global optimization? Do I lose performance?
Actually, the .NET JIT can inline function calls even across assembly
borders: If your helper functions are in one assembly, the code that uses
them in another one, the JIT will still be able to inline the calls.
Niki