InAttribute 클래스

정의

데이터가 호출자에서 피호출자로 마샬링되어야 하고, 호출자에게는 다시 마샬링되지 않아도 됨을 나타냅니다.

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

예제

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

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

설명

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

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

C#스타일 out 키워드로 수정된 매개 변수에는 적용 InAttribute 할 수 없습니다. Visual Basic 키워드를 빼기 특성과 InAttribute혼동 In 하지 않도록 하려면 특성 주위에 대괄호가 있는 양식을 사용합니다<[In]>.

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

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

생성자

InAttribute()

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

속성

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)

적용 대상

추가 정보