Click here to Skip to main content
15,906,574 members
Home / Discussions / C#
   

C#

 
QuestionListview ploblem? Pin
abcomp018-Aug-07 2:35
abcomp018-Aug-07 2:35 
AnswerRe: Listview ploblem? Pin
Hessam Jalali8-Aug-07 3:14
Hessam Jalali8-Aug-07 3:14 
GeneralRe: Listview ploblem? Pin
abcomp018-Aug-07 3:41
abcomp018-Aug-07 3:41 
GeneralRe: Listview ploblem? Pin
Hessam Jalali8-Aug-07 4:00
Hessam Jalali8-Aug-07 4:00 
Questionmouse posistion on a control when drag and dropped onto Pin
racing578-Aug-07 2:34
racing578-Aug-07 2:34 
AnswerRe: mouse posistion on a control when drag and dropped onto Pin
JoeSharp8-Aug-07 2:41
JoeSharp8-Aug-07 2:41 
GeneralRe: mouse posistion on a control when drag and dropped onto Pin
racing578-Aug-07 2:44
racing578-Aug-07 2:44 
GeneralRe: mouse posistion on a control when drag and dropped onto Pin
Luc Pattyn8-Aug-07 2:49
sitebuilderLuc Pattyn8-Aug-07 2:49 
GeneralRe: mouse posistion on a control when drag and dropped onto Pin
racing578-Aug-07 2:51
racing578-Aug-07 2:51 
QuestionIs there is some feature in C# that will act like #Define in C++ ??? Pin
Yanshof8-Aug-07 2:16
Yanshof8-Aug-07 2:16 
AnswerRe: Is there is some feature in C# that will act like #Define in C++ ??? Pin
Luc Pattyn8-Aug-07 2:29
sitebuilderLuc Pattyn8-Aug-07 2:29 
AnswerRe: Is there is some feature in C# that will act like #Define in C++ ??? Pin
Colin Angus Mackay8-Aug-07 2:30
Colin Angus Mackay8-Aug-07 2:30 
GeneralRe: Is there is some feature in C# that will act like #Define in C++ ??? Pin
Dan Neely8-Aug-07 3:43
Dan Neely8-Aug-07 3:43 
AnswerRe: Is there is some feature in C# that will act like #Define in C++ ??? Pin
User 66588-Aug-07 2:35
User 66588-Aug-07 2:35 
AnswerRe: Is there is some feature in C# that will act like #Define in C++ ??? Pin
PIEBALDconsult8-Aug-07 5:48
mvePIEBALDconsult8-Aug-07 5:48 
QuestionProblem- Server Busy...Switch/Retry Pin
Iftekhar Naim8-Aug-07 2:04
Iftekhar Naim8-Aug-07 2:04 
QuestionReflection, Invoking Methods Pin
glFrustum8-Aug-07 2:01
glFrustum8-Aug-07 2:01 
AnswerRe: Reflection, Invoking Methods Pin
kubben8-Aug-07 2:27
kubben8-Aug-07 2:27 
GeneralRe: Reflection, Invoking Methods Pin
glFrustum8-Aug-07 3:08
glFrustum8-Aug-07 3:08 
GeneralRe: Reflection, Invoking Methods Pin
kubben8-Aug-07 3:16
kubben8-Aug-07 3:16 
GeneralRe: Reflection, Invoking Methods Pin
glFrustum8-Aug-07 4:08
glFrustum8-Aug-07 4:08 
AnswerRe: Reflection, Invoking Methods Pin
J4amieC8-Aug-07 3:32
J4amieC8-Aug-07 3:32 
glFrustum wrote:
I'm looking for a nicer way to invoke methods. The following code is called by:
Fetch(someObject, "GetCustomer", 1).

The ugly thing about this is that the name of the method is passed as a string. Is there a way to support something like:
Fetch(someObject.GetCustomer, 1)?


Im still searching for the reason why you think the latter is preferable to the former. In answer to your question, if all the methods you want to call from your Fetch method have the same signature you could use delegates insstead of reflection (which identifies methods/properties the same way you do - by name).

eg. Say this is a data layer you are writing and the Fetch method is responsible for getting data from a vasiety of methods which follow this signature:

DataSet SomeGetDataMethod(object [] parameters)

you would define a delegate along the lines of

public delegate DataSet GetDataDelegate(object[] parameters);

You would then define your Fetch method as follows

public DataSet Fetch(GetDataDelegate method, object[] parameters)
{
   // you could async invoke the method here. This is sync for illustration
   method.Invoke(parameters);
}


Then to call this method you could have:

object[] parameters = new object{ 1 };<br />
Fetch( new GetDataDelegate(someObject.GetCustomer), parameters)


you could then pass a delegate to any of your data methods into this fetch method without using reflection.






Personally id stick with reflection!


GeneralRe: Reflection, Invoking Methods Pin
glFrustum8-Aug-07 4:00
glFrustum8-Aug-07 4:00 
GeneralRe: Reflection, Invoking Methods Pin
J4amieC8-Aug-07 4:43
J4amieC8-Aug-07 4:43 
GeneralRe: Reflection, Invoking Methods [modified] Pin
glFrustum8-Aug-07 4:47
glFrustum8-Aug-07 4:47 

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.