Well, the properties of the ParameterInfo
class are confusing me.
Unfortunately, the documentation is not very clear: the examples show how to create methods, but they donβt show how these methods look in C #.
Someone will tell Kana more about these properties:
DefaultValue
HasDefaultValue
IsIn
IsLcid
IsOptional
IsOut
IsRetval
And what combination leads to what method parameters.
I made a simple program that gives the following result:
Method Name M1 void M1(object param)
IL Signature: .method public hidebysig instance void M1(object param) cil managed
Parameter parameter description:
Follows the False link
HasDefaultValue = False
ISIN = False
IsLcid = False
IsOptional = False
IsOut = False
IsRetVal = False
Method name M2 void M2(object param = null)
IL signature .method public hidebysig instance void M2([opt] object param) cil managed
Parameter parameter description:
Follows the False link
HasDefaultValue = True
DefaultValue = zero
ISIN = False
IsLcid = False
IsOptional = True
IsOut = False
IsRetVal = False
Method Name M3 void M3(out object param)
IL signature .method public hidebysig instance void M3([out] object& param) cil managed
Parameter parameter description:
Submitted by True link
HasDefaultValue = False
ISIN = False
IsLcid = False
IsOptional = False
IsOut = True
IsRetVal = False
Method Name M4 void M4(ref object param)
IL signature .method public hidebysig instance void M4(object& param) cil managed
Parameter parameter description:
Submitted by True link
HasDefaultValue = False
ISIN = False
IsLcid = False
IsOptional = False
IsOut = False
IsRetVal = False
Method Name M5 void M5([In] object param)
IL signature .method public hidebysig instance void M5([in] object param) cil managed
Parameter parameter description:
Follows the False link
HasDefaultValue = False
ISIN = True
IsLcid = False
IsOptional = False
IsOut = False
IsRetVal = False
Method Name M6 void M6([Out] object param)
IL signature .method public hidebysig instance void M6([out] object param) cil managed
Parameter parameter description:
Follows the False link
HasDefaultValue = False
ISIN = False
IsLcid = False
IsOptional = False
IsOut = True
IsRetVal = False
Method name M7 void M7([Out] out object param)
Signature IL .method public hidebysig instance void M7([out] object& param) cil managed
Parameter parameter description:
Submitted by True link
HasDefaultValue = False
ISIN = False
IsLcid = False
IsOptional = False
IsOut = True
IsRetVal = False
Method Name M8 void M8([DefaultValue(null)] object param)
Signature IL .method public hidebysig instance void M8(object param) cil managed
Parameter parameter description:
Follows the False link
HasDefaultValue = False
ISIN = False
IsLcid = False
IsOptional = False
IsOut = False
IsRetVal = False
Method name M9 void M9([DefaultValue(-10)] int param = 10)
IL signature .method public hidebysig instance void M9([opt] int32 param) cil managed
Parameter parameter description:
Param parameter name
Follows the False link
HasDefaultValue = True
DefaultValue = 10
ISIN = False
IsLcid = False
IsOptional = True
IsOut = False
IsRetVal = False
Method Name M10 void M10([Optional] int param)
Signature IL .method public hidebysig instance void M10([opt] int32 param) cil managed
Parameter parameter description:
Follows the False link
HasDefaultValue = False
ISIN = False
IsLcid = False
IsOptional = True
IsOut = False
IsRetVal = False
I think the In
, Out
and Optional
attributes are for COM since they are in the System.Runtime.InteropServices namesapce.
But again, the documentation is pretty bad .:(
What is RetVal and where is it used?
source share