473,320 Members | 1,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

GetMethod

Hi all,

when using the GetMethod method to discover object methods at runtime, we
are suposed to pass an array of types as parameters.

My simple question is this:

how do you state that one of the parameters is by reference (i.e. void
myMethod(ref object) )?
in other words, if I have the following types array:

Type[] parmTypes = new Type[3];

parmTypes[0] = Type.GetType("System.String");

parmTypes[1] = Type.GetType("System.String");

parmTypes[2] = Type.GetType("System.String");

I wish to state that one or all of them is a 'ref' argument.

Thanx,

Picho
Nov 15 '05 #1
2 1994
Picho <pi***********@telhai.ac.il> wrote:
when using the GetMethod method to discover object methods at runtime, we
are suposed to pass an array of types as parameters.

My simple question is this:

how do you state that one of the parameters is by reference (i.e. void
myMethod(ref object) )?
in other words, if I have the following types array:

Type[] parmTypes = new Type[3];
parmTypes[0] = Type.GetType("System.String");
parmTypes[1] = Type.GetType("System.String");
parmTypes[2] = Type.GetType("System.String");

I wish to state that one or all of them is a 'ref' argument.


I believe you just append an "&" at the end:

parmTypes[2] = Type.GetType("System.String&");

Note that for "normal" parameters, a simpler way of specifying the type
is using the typeof operator:

parmTypes[0] = typeof(string);

I believe that in the next version of .NET there'll be a way of getting
a "by reference" version of a "normal" type, which will make all this
significantly easier.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #2
Thanx Jon,

I realized tht after invoking a GetParameters after GetMethod(string name)
on a test method that had a ref argument...

Picho
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Picho <pi***********@telhai.ac.il> wrote:
when using the GetMethod method to discover object methods at runtime, we are suposed to pass an array of types as parameters.

My simple question is this:

how do you state that one of the parameters is by reference (i.e. void
myMethod(ref object) )?
in other words, if I have the following types array:

Type[] parmTypes = new Type[3];
parmTypes[0] = Type.GetType("System.String");
parmTypes[1] = Type.GetType("System.String");
parmTypes[2] = Type.GetType("System.String");

I wish to state that one or all of them is a 'ref' argument.


I believe you just append an "&" at the end:

parmTypes[2] = Type.GetType("System.String&");

Note that for "normal" parameters, a simpler way of specifying the type
is using the typeof operator:

parmTypes[0] = typeof(string);

I believe that in the next version of .NET there'll be a way of getting
a "by reference" version of a "normal" type, which will make all this
significantly easier.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

16
by: AxlsPixel | last post by:
Hi All, I have a class (called CTestClass) within which I have a method (Foo). This method has the following signature: Foo(int x, int y, ref int z) I am attempting to use reflection to...
1
by: AngryGerbil | last post by:
hey, How do I acquire MethodInfo WITHOUT hardcoding method name as a string?!??!The fact I have to use xxx.Gettype.GetMethod("MyMethod", xxx) is making me want to drive an ice pick into my eye! I...
7
by: perspolis | last post by:
Hi I saw this fragment code somewhere. MethodInfo mi=dg.GetType().GetMethod("get_DataGridRows"); I know that that code gets info about get_DataGridRows method. but I can't find this code in...
6
by: Paul Welter | last post by:
I'm trying to get a method using Type.GetMethod. There are two methods with that same name, one is a standard method, the other is a Generic method. How do I get the Generic method? Is there a...
8
by: AngryGerbil | last post by:
hey, How do I acquire MethodInfo WITHOUT hardcoding method name as a string?!??!The fact I have to use xxx.Gettype.GetMethod("MyMethod", xxx) is making me want to drive an ice pick into my eye! I...
1
by: Andrus | last post by:
I need to call method by its name as string. To test it I created the following sample but GetMethod() returns null. Why ? Andrus. using System.Reflection; namespace BlogSample {
1
by: =?Utf-8?B?Q2xhdWRl?= | last post by:
TValue oItem = (TValue)Activator.CreateInstance(typeof(TValue), BindingFlags.Instance | BindingFlags.NonPublic, null, new object { m_nCleTemporaire },...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.