Click here to Skip to main content
15,860,859 members
Home / Discussions / C#
   

C#

 
GeneralRe: Implementing Private Inheritence Pin
Peter_in_27803-Oct-12 19:50
professionalPeter_in_27803-Oct-12 19:50 
AnswerRe: Implementing Private Inheritence Pin
Pete O'Hanlon3-Oct-12 22:19
subeditorPete O'Hanlon3-Oct-12 22:19 
AnswerRe: Implementing Private Inheritence Pin
jschell4-Oct-12 11:39
jschell4-Oct-12 11:39 
Questionprocess being called by C# app Pin
rachel_m3-Oct-12 18:28
rachel_m3-Oct-12 18:28 
AnswerRe: process being called by C# app Pin
Smart Arab3-Oct-12 20:54
Smart Arab3-Oct-12 20:54 
QuestionFail Read Int64 value from binary file created by C++ Pin
kisetsu3-Oct-12 14:49
kisetsu3-Oct-12 14:49 
QuestionThere is an error in XML document calling a PHP Webservice Pin
RalphGielkens3-Oct-12 10:54
RalphGielkens3-Oct-12 10:54 
QuestionPassing object[] Elements as Parameters to Invoke() Pin
ezazazel3-Oct-12 7:04
ezazazel3-Oct-12 7:04 
Hi guys!
Maybe anyone can help me with this:

I have a object[] with values e.g.:
C#
object[] obj = new object[]{"a",1};

Furthermore I have a dynamic method which is in reality for example a
C#
Func<string,int,int> function;


Is there a way to use the values of the object[] as parameters for the function?
Or how can I invoke the method with the values from the object[]?

-----------------
Why is this needed?
I have classes which store Func<1..n> within a dynamic property
e.g.
C#
class A
public dynamic Algorithm;
Algorithm = new System.Func<int,int,int>((x,y) => { return x + y; });

class B
public dynamic Algorithm;
Algorithm = new System.Func<double,double,int,double>((x,y) => { return x / y * z; });
.
By iterating through MethodInfo[] I get
C#
Type inputType = parameter.ParameterType;
Type returnType = member.ReturnType;
and can therefore create my UI.

Now I can create objects out of this by using the Activator
C#
object inputParameterObject = Activator.CreateInstance(inputType);


In the UI I fill in the values.
C#
inputParameterObject1 = a;
inputParameterObject2 = 1;

The inputParameterObjects are stored in an object[]

Now I need to invoke the Func<1..n> by passing the values from the UI.
C#
Algorithm.Invoke(inputParameterObjectArray);

does not work as it is not equal to
C#
Algorithm.Invoke("a",1);

Or in other words
C#
Algorithm.Invoke(object[]) != Algorithm.Invoke(string,int) || Algorithm.Invoke(object,object)


Help would be appreciated!
So long,

modified 3-Oct-12 13:40pm.

AnswerRe: Passing object[] Elements as Parameters to Invoke() Pin
Matt T Heffron3-Oct-12 9:08
professionalMatt T Heffron3-Oct-12 9:08 
GeneralRe: Passing object[] Elements as Parameters to Invoke() Pin
ezazazel3-Oct-12 19:26
ezazazel3-Oct-12 19:26 
QuestionC# calling executable Pin
dcof3-Oct-12 3:57
dcof3-Oct-12 3:57 
AnswerRe: C# calling executable Pin
Pete O'Hanlon3-Oct-12 4:16
subeditorPete O'Hanlon3-Oct-12 4:16 
AnswerRe: C# calling executable Pin
Shameel3-Oct-12 4:51
professionalShameel3-Oct-12 4:51 
AnswerRe: C# calling executable Pin
Dave Kreskowiak3-Oct-12 5:35
mveDave Kreskowiak3-Oct-12 5:35 
GeneralRe: C# calling executable Pin
dcof3-Oct-12 8:07
dcof3-Oct-12 8:07 
GeneralRe: C# calling executable Pin
Pete O'Hanlon3-Oct-12 8:38
subeditorPete O'Hanlon3-Oct-12 8:38 
GeneralRe: C# calling executable Pin
Dave Kreskowiak3-Oct-12 13:45
mveDave Kreskowiak3-Oct-12 13:45 
QuestionC# Windows application not responding after 30 minutes Pin
sujithkumarsl2-Oct-12 10:13
sujithkumarsl2-Oct-12 10:13 
AnswerRe: C# Windows application not responding after 30 minutes Pin
Smart Arab2-Oct-12 10:58
Smart Arab2-Oct-12 10:58 
AnswerRe: C# Windows application not responding after 30 minutes Pin
Dave Kreskowiak2-Oct-12 12:35
mveDave Kreskowiak2-Oct-12 12:35 
GeneralOT Pin
Peter_in_27802-Oct-12 22:08
professionalPeter_in_27802-Oct-12 22:08 
GeneralRe: OT Pin
Dave Kreskowiak3-Oct-12 2:22
mveDave Kreskowiak3-Oct-12 2:22 
GeneralRe: OT Pin
Peter_in_27803-Oct-12 2:29
professionalPeter_in_27803-Oct-12 2:29 
GeneralRe: OT Pin
Dave Kreskowiak3-Oct-12 5:24
mveDave Kreskowiak3-Oct-12 5:24 
GeneralRe: C# Windows application not responding after 30 minutes Pin
sujithkumarsl3-Oct-12 4:36
sujithkumarsl3-Oct-12 4:36 

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.