What does attribute return in C # mean?

I have a code like this:

[return: XmlElement("return", Namespace = "", IsNullable = false, DataType = "base64Binary")]
public byte[] WORK([XmlElement(Namespace = "http://www.example.com/xml/someapi", DataType = "string", Form = XmlSchemaForm.Qualified)] string guid, [XmlElement(Namespace = "http://www.example.com/xml/someapi", DataType = "base64Binary", Form = XmlSchemaForm.Qualified)] byte[] data) {

   // some work
}

what does attribute mean return:?

+4
source share
1 answer

I have never come across this before, but it seems to be described as attribute targets in Disabmbiguating Attribute Targets

This situation often occurs with marshaling. To allow ambiguity, C # has a default set of goals for each type of declaration, which can be overridden by explicitly specifying the purpose of the attribute. WITH#

// default: applies to method 
[SomeAttr] 
int Method1() { return 0; } 

// applies to method 
[method: SomeAttr] 
int Method2() { return 0; } 

// applies to return value 
[return: SomeAttr] 
int Method3() { return 0; } 

, , SomeAttr ; , SomeAttr , . , AttributeUsage . . AttributeUsage ( #). : [target: attribute-list]

+2

All Articles