1 <?xml version="1.0" encoding="utf-8"?>
2 <Type Name="ReturnValueNameAttribute" FullName="System.Runtime.InteropServices.WindowsRuntime.ReturnValueNameAttribute">
3 <TypeSignature Language="C#" Value="public sealed class ReturnValueNameAttribute : Attribute" />
4 <TypeSignature Language="ILAsm" Value=".class public auto ansi sealed beforefieldinit ReturnValueNameAttribute extends System.Attribute" />
6 <AssemblyName>mscorlib</AssemblyName>
7 <AssemblyVersion>4.0.0.0</AssemblyVersion>
10 <BaseTypeName>System.Attribute</BaseTypeName>
15 <AttributeName>System.AttributeUsage(System.AttributeTargets.Delegate | System.AttributeTargets.ReturnValue | System.AttributeTargets.All, AllowMultiple=false, Inherited=false)</AttributeName>
20 <attribution license="cc4" from="Microsoft" modified="false" />
21 <para>In a wrt component, all the parameters of a method and the return value must have names. By default, <format type="text/html"><a href="d2ce0683-343d-403e-bb8d-209186f7a19d">Winmdexp.exe (Windows Runtime Metadata Export Tool)</a></format> gives the return value the name "value". When you use a component in a win8_appname_long app written in JavaScript, you can use this name to retrieve the return value. For example, suppose a component defines a method that has a return value and two out parameters (ByRef parameters with the <see cref="T:System.Runtime.InteropServices.OutAttribute" /> attribute in Visual Basic):</para>
22 <code>public static int ComputeAverage([ReadOnlyArray()] int[] input,
23 out int minValue, out int maxValue)
28 <code>Public Shared Function ComputeAverage( _
29 <ReadOnlyArray()> ByVal input As Integer, _
30 <Out()> ByRef minValue As Integer, _
31 <Out()> ByRef maxValue As Integer) As Integer
35 <para>When you call the function from JavaScript, you can access the return value by its default name (value): </para>
36 <code> var data = [5, 13, 23, 37];
37 var results = SampleComponent.TestStuff.computeAverage(data);
38 var formattedResults = "Min=" + results.minValue + ", Avg=" +
39 results.value + ", Max=" + results.maxValue;
41 <para>You must give the return value a different name if you already have a parameter named "value". Or you might simply want to use a more meaningful name (such as "average" in this example). Apply the <see cref="T:System.Runtime.InteropServices.WindowsRuntime.ReturnValueNameAttribute" /> attribute to your method and specify a new name. </para>
42 <code>[return: ReturnValueName("average")]
43 public static int ComputeAverage([ReadOnlyArray()] int[] input,
44 out int minValue, out int maxValue)
49 <code>Public Shared Function ComputeAverage( _
50 <ReadOnlyArray()> ByVal input As Integer, _
51 <Out()> ByRef minValue As Integer, _
52 <Out()> ByRef maxValue As Integer) _
53 As <ReturnValueName("average")> Integer
59 <attribution license="cc4" from="Microsoft" modified="false" />
60 <para>Specifies the name of the return value of a method in a wrt component.</para>
64 <Member MemberName=".ctor">
65 <MemberSignature Language="C#" Value="public ReturnValueNameAttribute (string name);" />
66 <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(string name) cil managed" />
67 <MemberType>Constructor</MemberType>
69 <AssemblyVersion>4.0.0.0</AssemblyVersion>
72 <Parameter Name="name" Type="System.String" />
75 <remarks>To be added.</remarks>
77 <attribution license="cc4" from="Microsoft" modified="false" />
78 <para>Initializes a new instance of the <see cref="T:System.Runtime.InteropServices.WindowsRuntime.ReturnValueNameAttribute" /> class, and specifies the name of the return value.</para>
81 <attribution license="cc4" from="Microsoft" modified="false" />The name of the return value. </param>
84 <Member MemberName="Name">
85 <MemberSignature Language="C#" Value="public string Name { get; }" />
86 <MemberSignature Language="ILAsm" Value=".property instance string Name" />
87 <MemberType>Property</MemberType>
89 <AssemblyVersion>4.0.0.0</AssemblyVersion>
92 <ReturnType>System.String</ReturnType>
95 <value>To be added.</value>
96 <remarks>To be added.</remarks>
98 <attribution license="cc4" from="Microsoft" modified="false" />
99 <para>Gets the name that was specified for the return value of a method in a wrt component.</para>