In C++ there is a float value being put into an int:
int value = *(int *)(&myFloatValue);
This value gets passed to a program I am writing in C#. It is not known at run-time whether the value will be of type int or of float. I must account for both options. Obviously if it is an int, I already have it. However if it is a float I need to change it (not cast) it its float value. How do I do this? I tried using pointers in C# but that was unsuccessful.
Do the reverse in your C# code:
And that should work.
(Just make sure that value isn’t inside of a managed type, it must be on its own)
EDIT: Make sure you declare the body of code you are doing this in as
unsafe