확장 최소화
이 항목은 아직 평가되지 않았습니다.- 이 항목 평가

TypeBuilder.MakePointerType 메서드

참고: 이 메서드는 .NET Framework 버전 2.0에서 새로 추가되었습니다.

현재 형식에 대한 관리되지 않는 포인터의 형식을 나타내는 Type 개체를 반환합니다.

네임스페이스: System.Reflection.Emit
어셈블리: mscorlib(mscorlib.dll)

public override Type MakePointerType ()
public Type MakePointerType ()
public override function MakePointerType () : Type

반환 값

현재 형식에 대한 관리되지 않는 포인터의 형식을 나타내는 Type 개체입니다.

MakePointerType 메서드는 매개 변수 목록의 포인터 형식을 생성하는 데 사용할 수 있습니다.

Note참고

MSIL(Microsoft Intermediate Language) 구문을 사용하는 경우 현재 TypeBuilderMyType을 나타내면 이 메서드에서 반환되는 형식은 MyType*이 됩니다.

다음 코드 예제에서는 동적 모듈, 추상 형식 Sample 및 추상 메서드 TestMethod를 만듭니다. TestMethodSample 형식의 ref 매개 변수(Visual Basic의 경우 ByRef), Sample 형식에 대한 포인터 및 Sample 형식의 배열을 사용합니다. 이 메서드는 Sample 형식의 2차원 배열을 반환합니다. 이 코드 예제에서는 동적 모듈을 디스크에 저장하므로 MSIL 디스어셈블러(Ildasm.exe)를 사용하여 동적 모듈을 검사할 수 있습니다.

using System;
using System.Reflection;
using System.Reflection.Emit;
using Microsoft.VisualBasic;

public class Example
{
    public static void Main()
    {
        // Define a dynamic assembly to contain the sample type. The
        // assembly will not be run, but only saved to disk, so
        // AssemblyBuilderAccess.Save is specified.
        //
        AppDomain myDomain = AppDomain.CurrentDomain;
        AssemblyName myAsmName = new AssemblyName("MakeXxxTypeExample");
        AssemblyBuilder myAssembly = myDomain.DefineDynamicAssembly(
            myAsmName, 
            AssemblyBuilderAccess.Save);

        // An assembly is made up of executable modules. For a single-
        // module assembly, the module name and file name are the same 
        // as the assembly name. 
        //
        ModuleBuilder myModule = myAssembly.DefineDynamicModule(
            myAsmName.Name, 
            myAsmName.Name + ".dll");

        // Define the sample type.
        TypeBuilder myType = myModule.DefineType(
            "Sample", 
            TypeAttributes.Public | TypeAttributes.Abstract);

        // Define a method that takes a ref argument of type Sample,
        // a pointer to type Sample, and an array of Sample objects. The
        // method returns a two-dimensional array of Sample objects.
        //
        // To create this method, you need Type objects that represent the
        // parameter types and the return type. Use the MakeByRefType, 
        // MakePointerType, and MakeArrayType methods to create the Type
        // objects.
        //
        Type byRefMyType = myType.MakeByRefType();
        Type pointerMyType = myType.MakePointerType();
        Type arrayMyType = myType.MakeArrayType();
        Type twoDimArrayMyType = myType.MakeArrayType(2);

        // Create the array of parameter types.
        Type[] parameterTypes = {byRefMyType, pointerMyType, arrayMyType};

        // Define the abstract Test method. After you have compiled
        // and run this code example code, you can use ildasm.exe 
        // to open MakeXxxTypeExample.dll, examine the Sample type,
        // and verify the parameter types and return type of the
        // TestMethod method.
        //
        MethodBuilder myMethodBuilder = myType.DefineMethod(
            "TestMethod", 
            MethodAttributes.Abstract | MethodAttributes.Virtual 
                | MethodAttributes.Public,
            twoDimArrayMyType,
            parameterTypes);

        // Create the type and save the assembly. For a single-file 
        // assembly, there is only one module to store the manifest 
        // information in.
        //
        myType.CreateType();
        myAssembly.Save(myAsmName.Name + ".dll");
    }
}

import System.*;
import System.Reflection.*;
import System.Reflection.Emit.*;
import Microsoft.VisualBasic.*;

public class Example
{
    public static void main(String[] args)
    {
        // Define a dynamic assembly to contain the sample type. The
        // assembly will not be run, but only saved to disk, so
        // AssemblyBuilderAccess.Save is specified.
        //
        AppDomain myDomain = AppDomain.get_CurrentDomain();
        AssemblyName myAsmName = new AssemblyName("MakeXxxTypeExample");
        AssemblyBuilder myAssembly = myDomain.DefineDynamicAssembly(myAsmName, 
            AssemblyBuilderAccess.Save);
        // An assembly is made up of executable modules. For a single-
        // module assembly, the module name and file name are the same 
        // as the assembly name. 
        //
        ModuleBuilder myModule = myAssembly.DefineDynamicModule(
            myAsmName.get_Name(), myAsmName.get_Name() + ".dll");
        // Define the sample type.
        TypeBuilder myType = myModule.DefineType("Sample", TypeAttributes.Public 
            | TypeAttributes.Abstract);
        // Define a method that takes a ref argument of type Sample,
        // a pointer to type Sample, and an array of Sample objects. The
        // method returns a two-dimensional array of Sample objects.
        //
        // To create this method, you need Type objects that represent the
        // parameter types and the return type. Use the MakeByRefType, 
        // MakePointerType, and MakeArrayType methods to create the Type
        // objects.
        //
        Type byRefMyType = myType.MakeByRefType();
        Type pointerMyType = myType.MakePointerType();
        Type arrayMyType = myType.MakeArrayType();
        Type twoDimArrayMyType = myType.MakeArrayType(2);
        // Create the array of parameter types.
        Type parameterTypes[] =  { byRefMyType, pointerMyType, arrayMyType };
        // Define the abstract Test method. After you have compiled
        // and run this code example code, you can use ildasm.exe 
        // to open MakeXxxTypeExample.dll, examine the Sample type,
        // and verify the parameter types and return type of the
        // TestMethod method.
        //
        MethodBuilder myMethodBuilder = myType.DefineMethod("TestMethod", 
            MethodAttributes.Abstract | MethodAttributes.Virtual 
            | MethodAttributes.Public, twoDimArrayMyType, parameterTypes);
        // Create the type and save the assembly. For a single-file 
        // assembly, there is only one module to store the manifest 
        // information in.
        //
        myType.CreateType();
        myAssembly.Save((myAsmName.get_Name() + ".dll"));
    } //main
} //Example

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

.NET Framework

2.0에서 지원
이 정보가 도움이 되었습니까?
(1500자 남음)

커뮤니티 추가 항목

추가
© 2013 Microsoft. All rights reserved.