Click here to Skip to main content
12,396,961 members (40,986 online)
   

C#

 
GeneralRe: Create a button in the context menu for each selected contact. Pin
csharpcomeintome5-Nov-12 21:46
membercsharpcomeintome5-Nov-12 21:46 
GeneralRe: Create a button in the context menu for each selected contact. Pin
Eddy Vluggen5-Nov-12 23:40
memberEddy Vluggen5-Nov-12 23:40 
GeneralRe: Create a button in the context menu for each selected contact. Pin
csharpcomeintome5-Nov-12 23:44
membercsharpcomeintome5-Nov-12 23:44 
GeneralRe: Create a button in the context menu for each selected contact. Pin
Eddy Vluggen5-Nov-12 23:54
memberEddy Vluggen5-Nov-12 23:54 
GeneralRe: Create a button in the context menu for each selected contact. Pin
csharpcomeintome6-Nov-12 0:16
membercsharpcomeintome6-Nov-12 0:16 
GeneralRe: Create a button in the context menu for each selected contact. Pin
Eddy Vluggen6-Nov-12 0:23
memberEddy Vluggen6-Nov-12 0:23 
GeneralRe: Create a button in the context menu for each selected contact. Pin
csharpcomeintome6-Nov-12 0:35
membercsharpcomeintome6-Nov-12 0:35 
GeneralRe: Create a button in the context menu for each selected contact. Pin
csharpcomeintome6-Nov-12 4:57
membercsharpcomeintome6-Nov-12 4:57 
GeneralRe: Create a button in the context menu for each selected contact. Pin
csharpcomeintome6-Nov-12 21:24
membercsharpcomeintome6-Nov-12 21:24 
GeneralRe: Create a button in the context menu for each selected contact. Pin
csharpcomeintome6-Nov-12 2:40
membercsharpcomeintome6-Nov-12 2:40 
GeneralRe: Create a button in the context menu for each selected contact. Pin
Eddy Vluggen6-Nov-12 2:42
memberEddy Vluggen6-Nov-12 2:42 
GeneralRe: Create a button in the context menu for each selected contact. Pin
csharpcomeintome6-Nov-12 2:46
membercsharpcomeintome6-Nov-12 2:46 
GeneralRe: Create a button in the context menu for each selected contact. Pin
Eddy Vluggen6-Nov-12 3:04
memberEddy Vluggen6-Nov-12 3:04 
QuestionProblem with Excel WorksheetFunction.Growth in c# Pin
Ross R4-Nov-12 23:17
memberRoss R4-Nov-12 23:17 
I have a document level application for Excel 2010 using VSTO and c#. The following code is used to call the Excel Growth function.

double[] known_Ys, new_Ys, known_Xs, new_Xs;
   // Both of the known arrays have a length of 7
   // The new arrays have a length of 5
   // All arrays were loaded with valid double values
   // except new_Ys which will contain the result
Excel.WorksheetFunction wsf = Application.WorksheetFunction;
object results = wsf.Growth(known_Ys, known_Xs, new_Xs, System.Type.Missing);

While debugging, "results" show a type of 'System.Object[*]' which is a System.Object[] with an undefined lower boundary.

Looking at the variable, there is an array of double values that appear to be correct. The lower boundary is 1, and the upper boundary is 5.

When attempting to cast the results to either object[] or double[], I get an exception, "Unable to cast object of type 'System.Object[*]' to type 'System.Object[]' or 'double[]'.

I've also unsuccessfully tried to use the static methods of the Array class to copy the contents out.

Any thoughts on a resolution would be appreciated.

I don't want to use VBA code to resolve the problem if it can be avoided.

I've also considered a work-around, using a hidden worksheet to perform the calculations and copying the results into the c# application, but feel I should be able to handle it in the c# code.


I found the following work-around, unless someone has a better solution.


"results" inherits from System.Array.

System.Array resultsArray = results as System.Array;
if (resultsArray != null)
{
   int idx = resultsArray.GetLowerBound(0);
   for (int i = 0; i < new_Ys.Length; i++)
   {
      new_Ys[i] = (double)resultsArray.GetValue(idx);
      idx++;
   }
   return new_Ys;
}
else
{
   // Handle exception.
   return null;
}

The conflict is that c# vectors (one dimensional arrays) are always zero based, so explicit casts won't work.

modified 5-Nov-12 6:46am.

Questionavoid double click Pin
neeraj@max4-Nov-12 20:06
memberneeraj@max4-Nov-12 20:06 
AnswerRe: avoid double click Pin
OriginalGriff4-Nov-12 20:34
mvpOriginalGriff4-Nov-12 20:34 
GeneralRe: avoid double click Pin
neeraj@max4-Nov-12 21:09
memberneeraj@max4-Nov-12 21:09 
GeneralRe: avoid double click Pin
J4amieC4-Nov-12 21:27
memberJ4amieC4-Nov-12 21:27 
GeneralRe: avoid double click Pin
neeraj@max4-Nov-12 23:25
memberneeraj@max4-Nov-12 23:25 
GeneralRe: avoid double click Pin
Pete O'Hanlon5-Nov-12 0:30
protectorPete O'Hanlon5-Nov-12 0:30 
GeneralRe: avoid double click Pin
J4amieC5-Nov-12 1:27
memberJ4amieC5-Nov-12 1:27 
GeneralRe: avoid double click Pin
neeraj@max5-Nov-12 1:43
memberneeraj@max5-Nov-12 1:43 
GeneralRe: avoid double click Pin
J4amieC5-Nov-12 1:52
memberJ4amieC5-Nov-12 1:52 
GeneralRe: avoid double click Pin
neeraj@max5-Nov-12 19:34
memberneeraj@max5-Nov-12 19:34 
GeneralRe: avoid double click Pin
J4amieC5-Nov-12 21:43
memberJ4amieC5-Nov-12 21:43 
GeneralRe: avoid double click Pin
neeraj@max6-Nov-12 0:08
memberneeraj@max6-Nov-12 0:08 
AnswerRe: avoid double click Pin
neeraj@max22-Nov-12 20:02
memberneeraj@max22-Nov-12 20:02 
QuestionHow to call C++ parameterised function from C# using thread Pin
sjs4u4-Nov-12 4:09
membersjs4u4-Nov-12 4:09 
AnswerRe: How to call C++ parameterised function from C# using thread Pin
Richard MacCutchan4-Nov-12 5:14
mvpRichard MacCutchan4-Nov-12 5:14 
AnswerRe: How to call C++ parameterised function from C# using thread Pin
DaveyM694-Nov-12 5:29
mentorDaveyM694-Nov-12 5:29 
QuestionHow to declare events? Pin
Andy_L_J3-Nov-12 20:41
memberAndy_L_J3-Nov-12 20:41 
AnswerRe: How to declare events? Pin
Richard MacCutchan3-Nov-12 21:32
mvpRichard MacCutchan3-Nov-12 21:32 
GeneralRe: How to declare events? Pin
Andy_L_J3-Nov-12 22:09
memberAndy_L_J3-Nov-12 22:09 
GeneralRe: How to declare events? Pin
Richard MacCutchan4-Nov-12 2:03
mvpRichard MacCutchan4-Nov-12 2:03 
AnswerRe: How to declare events? Pin
OriginalGriff3-Nov-12 21:33
mvpOriginalGriff3-Nov-12 21:33 
GeneralRe: How to declare events? Pin
Andy_L_J3-Nov-12 22:01
memberAndy_L_J3-Nov-12 22:01 
GeneralRe: How to declare events? Pin
OriginalGriff3-Nov-12 22:10
mvpOriginalGriff3-Nov-12 22:10 
GeneralRe: How to declare events? Pin
Andy_L_J3-Nov-12 22:26
memberAndy_L_J3-Nov-12 22:26 
GeneralRe: How to declare events? Pin
OriginalGriff3-Nov-12 22:32
mvpOriginalGriff3-Nov-12 22:32 
GeneralRe: How to declare events? Pin
DaveyM694-Nov-12 5:46
mentorDaveyM694-Nov-12 5:46 
GeneralRe: How to declare events? Pin
Andy_L_J4-Nov-12 12:37
memberAndy_L_J4-Nov-12 12:37 
GeneralRe: How to declare events? Pin
DaveyM694-Nov-12 19:23
mentorDaveyM694-Nov-12 19:23 
QuestionC# Search Button Pin
MikeK322-Nov-12 10:57
memberMikeK322-Nov-12 10:57 
AnswerRe: C# Search Button Pin
Marcus Kramer2-Nov-12 11:19
memberMarcus Kramer2-Nov-12 11:19 
GeneralRe: C# Search Button Pin
MikeK322-Nov-12 11:23
memberMikeK322-Nov-12 11:23 
GeneralRe: C# Search Button Pin
Marcus Kramer2-Nov-12 11:26
memberMarcus Kramer2-Nov-12 11:26 
GeneralRe: C# Search Button Pin
MikeK322-Nov-12 11:51
memberMikeK322-Nov-12 11:51 
GeneralRe: C# Search Button Pin
Marcus Kramer2-Nov-12 11:53
memberMarcus Kramer2-Nov-12 11:53 
Questioncase insensitive string comparison - relative speed Pin
Blake Miller2-Nov-12 9:31
memberBlake Miller2-Nov-12 9:31 
AnswerRe: case insensitive string comparison - relative speed Pin
Eddy Vluggen2-Nov-12 9:43
memberEddy Vluggen2-Nov-12 9:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web02 | 2.8.160721.1 | Last Updated 25 Jul 2016
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid