.NET Framework Bookmark and Share   
 index > Common Language Runtime > Marshal single, double datatype
 

Marshal single, double datatype

Is there a way to copy one single or doublevalue to IntPtr. Marshal.Copy takes an array of double or single. I wish totransfer data from the managed code (which uses ADO.NET ) to a inproc COM object in the same apartment.I'mpassing the address of thefield variables in COM object as IntPtr array to the managed code to transfer the whole row (fetched using DataReader)in one callfrom the managed assembly.

nitin74
You can easily just wrap your single or double value into an array, and use Marshal.Copy's current overload. For example, for a Single value:

void CopyToPointer(IntPtr copyTarget, float myFloat)
{
Marhsall.Copy(new float[] { myFloat }, 0, copyTarget, 1);
}


The result of this will be identical, since you're copying by value in any case.

Reed Copsey, Jr. - http://reedcopsey.com
Reed Copsey, Jr.

You can use google to search for other answers

Custom Search

More Threads

• Need pointers on calling Unmanaged Exe application from C# Windows application
• Money question about decimal and/or double usage when dealing with sql float.
• Used memory in task manager after restoring from minimization
• FileLoadException Could not load file or assembly 'OGLShell' or one of its dependencies
• crash in moscor dll
• How to make a VB.NET DLL for use in VC++??
• How to reserve disk space
• Unhandled Exception: System.TypeInitializationException before reaching my main function
• setting cultureInfo for Appdomain?
• Reusing classes without creating a dll