C#: Can I or how to assign attributes to method parameters? -
c# documentation says can assign custom attributes parameters. exact sentence is: "a target element can assembly, class, constructor, delegate, enum, event, field, interface, method, portable executable file module, parameter, property, return value, struct, or attribute." given that, correct syntax this:
private void somemethod ([customattribute(blah = "blah1")] string actualparam, [customattribute(blah = "blah2")] datetime anotherparam ) { // method's body } or missing entirely?
that's said. parameters, you'll like:
void somemethod([marshalas(unmanagedtype.functionptr)] action del); for return value, you'd do:
[return: myattribute(param1 = "value1")] int method() similarly, there [module: myattribute], [assembly: myattribute] modules , assemblies.
Comments
Post a Comment