TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Bhawna Tuteja
NA
544
277.9k
Converting DoubleArray To IntPtr and then to Byte Array
Feb 15 2017 12:44 AM
Hi,
I have requirement to convert double array to IntPtr and this IntPtr to byte array.
I want to do the reversal also just confirm values stored in byte array is of correct int array.
The steps I am following is
double[] dmanagedArray = new double[length];
for (int intI = 0; intI < dmanagedArray.Length; intI++)
{
dmanagedArray[intI] = intI * 10;
}
int size = Marshal.SizeOf(dmanagedArray[0]) * dmanagedArray.Length;
IntPtr srcPtr1 = Marshal.AllocHGlobal(size);
// This will copy double array to IntPtr.
Marshal.Copy(dmanagedArray, 0, srcPtr1, dmanagedArray.Length);
// Now let's convert this IntPtr to byte array
byte[] byteArray = new byte[dmanagedArray.Length]
//Marshal.Copy(srcPtr1, byteArray, 0, byteArray.Length);
In my case what is happening is , byte[] now contains all the values as 0.
which I think is wrong. How to do right conversion.
Reply
Answers (
1
)
Suggestion to Learn Method of ASP.Net Web Project
mvc and windows form