LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming, microsoft.public.dotnet.languages.csharp
external usenet poster
 
Posts: 15
Default efficient / easy way to convert an Excel.Range to a double[,]

This works well.
When transferring data from object[,] to double[,] - use copy method &
specify length of the array.
In this case it is 4 (2 rows, 2 columns)

See the code below for example.

object[,] data = new object[2,2];
data[0,0] = 0.5d;
data[0,1] = 1.5d;
data[1,0] = 2.0d;
data[1,1] = 5.5d;

double[,] ddata = new double[2,2];
Array.Copy(data, ddata, 4);
Console.WriteLine("ok");
ddata[0,0] = 3.5;

Console.WriteLine(ddata[0,0]);
Console.WriteLine(ddata[0,1]);
Console.WriteLine(ddata[1,0]);
Console.WriteLine(ddata[1,1]);

HTH
Kalpesh
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert excel (.xls) to tab delimited (.txt) without double quotat Andrea Excel Discussion (Misc queries) 3 January 13th 09 11:11 PM
is there an easy way to convert an word xp file to excel xp? Maniacal Zebra Excel Discussion (Misc queries) 1 June 25th 07 08:05 AM
most efficient large range summing? jonigr Excel Programming 5 May 10th 07 06:26 AM
Can anyone help me convert to more efficient code? slo Excel Programming 2 August 4th 06 05:01 PM
more efficient way to lookup a range? [email protected] Excel Discussion (Misc queries) 1 May 12th 06 05:41 AM


All times are GMT +1. The time now is 08:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"