Thanks for the response.
I tried attributes, it did not return anything.
array<Object^>^myAttributes = pi->GetCustomAttributes(false);
Length of myAttributes was 0. I also tried passing specific InAttribute and
OutAttribute typeid, that did not return either.
for each(Attribute^ attr in pi->GetCustomAttributes(InAttribute::typeid,
false))
{
do something..
}
I tried ParameterInfo->Attributes property, that returned empty
if(pi->Attributes == ParameterAttributes::In)
{
...
}
What else can I do here?
> Thanks for the response.
>
[quoted text clipped - 19 lines]
>
> What else can I do here?
Note also that the ParameterType->IsByRef is closely related to out and ref
parameters. In fact, if that isn't true, I think you can safely assume the
parameter is "In". For parameters which are ByRef, you need to check for
ref vs out.
>>> I'm using reflection API's to find the argument types of a methods
>>> (such as in or out etc). For example, consider this method
[quoted text clipped - 21 lines]
>>> Thanks
>>> Fiz
Fiz - 09 May 2008 21:11 GMT
> Note also that the ParameterType->IsByRef is closely related to out and ref
> parameters. In fact, if that isn't true, I think you can safely assume the
> parameter is "In". For parameters which are ByRef, you need to check for
> ref vs out.
Thanks. However, I'm back to the same question. If it is ByRef, how do I
check for ref vs out. I checked the properties and methods of ParameterType ,
couldn't find anything. Any hint? Any URL?
It shouldn't be that difficult, I'm missing something here :(
Ben Voigt [C++ MVP] - 09 May 2008 22:50 GMT
>> Note also that the ParameterType->IsByRef is closely related to out
>> and ref parameters. In fact, if that isn't true, I think you can
[quoted text clipped - 6 lines]
>
> It shouldn't be that difficult, I'm missing something here :(
ParameterInfo.Attributes and ParameterInfo.IsOut are working for me.
code:
[TestFixture]
public class OutParameter
{
[Test]
public static void test()
{
foreach (MethodInfo mi in
typeof(double).GetMethods(BindingFlags.Public | BindingFlags.Instance |
BindingFlags.Static))
{
System.Diagnostics.Trace.WriteLine(mi.Name + " : ");
foreach (ParameterInfo pi in mi.GetParameters())
{
System.Diagnostics.Trace.WriteLine(pi.Name + " > " +
pi.Attributes);
}
}
}
}
output:
[snip]
TryParse :
s > None
result > Out
[snip]