reflection - Convert c# by-reference type to the matching non-by-reference type -
reflection - Convert c# by-reference type to the matching non-by-reference type -
i examine parameters of c# method using reflection. method has out parameters , these types, have isbyref=true. illustration if parameter declared "out string xxx", parameter has type system.string&. there way convert system.string& system.string? solution should of course of study not work system.string type.
use type.getelementtype().
demo:
using system; using system.reflection; class test { public void foo(ref string x) { } static void main() { methodinfo method = typeof(test).getmethod("foo"); type stringbyref = method.getparameters()[0].parametertype; console.writeline(stringbyref); type normalstring = stringbyref.getelementtype(); console.writeline(normalstring); } } c# reflection
Comments
Post a Comment