OutAttribute 클래스

정의

데이터가 피호출자로부터 호출자로 마샬링 됨을 나타냅니다.

public ref class OutAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Parameter, Inherited=false)]
public sealed class OutAttribute : Attribute
[System.AttributeUsage(System.AttributeTargets.Parameter, Inherited=false)]
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class OutAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Parameter, Inherited=false)>]
type OutAttribute = class
    inherit Attribute
[<System.AttributeUsage(System.AttributeTargets.Parameter, Inherited=false)>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type OutAttribute = class
    inherit Attribute
Public NotInheritable Class OutAttribute
Inherits Attribute
상속
OutAttribute
특성

예제

다음 예에서는 및 를 플랫폼 호출 프로토타입에 적용 InAttributeOutAttribute 하여 배열을 매개 변수로 전달하는 방법을 보여 줍니다. 방향 특성의 조합을 사용하면 호출자가 호출자가 변경한 내용을 볼 수 있습니다.

using namespace System;
using namespace System::Runtime::InteropServices;

// Declare a class member for each structure element.

[StructLayout(LayoutKind::Sequential, CharSet = CharSet::Unicode)]
public ref class OpenFileName
{
public:
    int structSize;
    String^ filter;
    String^ file;
    // ...
};

private ref class NativeMethods
{
public:

    // Declare a managed prototype for the unmanaged function.

    [DllImport("Comdlg32.dll", CharSet = CharSet::Unicode)]
    static bool GetOpenFileName([In, Out]OpenFileName^ ofn);
};

void main() {}
using System.Runtime.InteropServices;
using System;

// Declare a class member for each structure element.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
public class OpenFileName
{
    public int structSize = 0;
    public string filter = null;
    public string file = null;
    // ...
}

internal static class NativeMethods
{
    // Declare a managed prototype for the unmanaged function.
    [DllImport("Comdlg32.dll", CharSet = CharSet.Unicode)]
    internal static extern bool GetOpenFileName([In, Out] OpenFileName ofn);
}

public class MainMethod
{
    static void Main()
    { }
}
Imports System.Runtime.InteropServices

' Declare a class member for each structure element.
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode)>
Public Class OpenFileName

    Public structSize As Integer = 0
    Public filter As String = Nothing
    Public file As String = Nothing
    ' ...

End Class

Friend Class NativeMethods
    ' Declare managed prototype for the unmanaged function.
    Friend Declare Unicode Function GetOpenFileName Lib "Comdlg32.dll" (
       <[In](), Out()> ByVal ofn As OpenFileName) As Boolean
End Class

Public Class App
    Public Shared Sub Main()

    End Sub
End Class

설명

매개 변수에 이 특성을 적용할 수 있습니다.

OutAttribute 선택 사항입니다. 특성은 COM interop 및 플랫폼 호출에 대해서만 지원됩니다. 명시적 설정이 없는 경우 interop 마샬러는 매개 변수 형식, 매개 변수가 참조 또는 값으로 전달되는지 여부, 형식이 Blittable인지 아니면 Blittable이 아닌지 여부에 따라 규칙을 가정합니다. 예를 들어 StringBuilder 클래스는 항상 In/Out으로 간주되고 값으로 전달된 문자열 배열은 In으로 간주됩니다.

아웃 전용 동작은 매개 변수에 대한 기본 마샬링 동작이 되지 않습니다. 참조로 전달된 값 및 참조 형식에 를 적용 OutAttribute 하여 In/Out 동작을 C#에서 키워드를 사용하는 out 것과 동일한 Out 전용 동작으로 변경할 수 있습니다. 예를 들어 기본적으로 In-only 매개 변수로 마샬링된 값으로 전달된 배열을 Out 전용으로 변경할 수 있습니다. 그러나 interop 마샬러가 고정을 사용하기 때문에 형식에 모든 Blittable 요소 또는 필드가 포함된 경우 동작이 항상 예상 의미 체계를 제공하지는 않습니다. 호출 수신자에게 데이터를 전달하는 데 신경 쓰지 않는 경우 아웃 전용 마샬링이 Blittable이 아닌 형식에 대해 더 나은 성능을 제공할 수 있습니다.

OutAttribute 를 결합하는 InAttribute 것은 배열에 적용하고 blittable이 아닌 형식으로 서식이 지정된 경우에 특히 유용합니다. 호출자는 두 특성을 모두 적용할 때만 호출 수신자가 이러한 형식에 대해 변경한 내용을 확인합니다. 이러한 형식은 마샬링하는 동안 복사해야 하므로 및 OutAttribute 를 사용하여 InAttribute 불필요한 복사본을 줄일 수 있습니다.

마샬링 동작의 OutAttribute 영향에 대한 자세한 내용은 방향 특성을 참조하세요.

생성자

OutAttribute()

OutAttribute 클래스의 새 인스턴스를 초기화합니다.

속성

TypeId

파생 클래스에서 구현된 경우 이 Attribute에 대한 고유 식별자를 가져옵니다.

(다음에서 상속됨 Attribute)

메서드

Equals(Object)

이 인스턴스가 지정된 개체와 같은지를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
GetHashCode()

이 인스턴스의 해시 코드를 반환합니다.

(다음에서 상속됨 Attribute)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
IsDefaultAttribute()

파생 클래스에서 재정의된 경우 이 인스턴스 값이 파생 클래스에 대한 기본값인지 여부를 표시합니다.

(다음에서 상속됨 Attribute)
Match(Object)

파생 클래스에서 재정의된 경우 이 인스턴스가 지정된 개체와 같은지 여부를 나타내는 값을 반환합니다.

(다음에서 상속됨 Attribute)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

이름 집합을 해당하는 디스패치 식별자 집합에 매핑합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

인터페이스의 형식 정보를 가져오는 데 사용할 수 있는 개체의 형식 정보를 검색합니다.

(다음에서 상속됨 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

개체에서 제공하는 형식 정보 인터페이스의 수를 검색합니다(0 또는 1).

(다음에서 상속됨 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

개체에서 노출하는 메서드와 속성에 대한 액세스를 제공합니다.

(다음에서 상속됨 Attribute)

적용 대상

추가 정보