CallingConventions 列挙型
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
メソッドの有効な呼び出し規約を定義します。
この列挙体は、メンバー値のビットごとの組み合わせをサポートしています。
public enum class CallingConventions
[System.Flags]
public enum CallingConventions
[System.Flags]
[System.Serializable]
public enum CallingConventions
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum CallingConventions
[<System.Flags>]
type CallingConventions =
[<System.Flags>]
[<System.Serializable>]
type CallingConventions =
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CallingConventions =
Public Enum CallingConventions
- 継承
- 属性
名前 | 値 | 説明 |
---|---|---|
Any | 3 |
|
ExplicitThis | 64 | シグネチャが、インスタンスまたは仮想メソッド (非静的メソッド) への呼び出しを表す関数ポインター シグネチャであることを示します。
|
HasThis | 32 | インスタンスまたは仮想メソッド (非静的メソッド) を指定します。 実行時に、呼び出されるメソッドに、目的のオブジェクトへのポインターが最初の引数 ( |
Standard | 1 | 共通言語ランタイムで決定されている既定の呼び出し規約を指定します。 この静的メソッドの呼び出し規約を使用します。 インスタンスや仮想メソッドには、 |
VarArgs | 2 | 引数の数が変化するメソッドの呼び出し規約を指定します。 |
using namespace System;
using namespace System::Reflection;
using namespace System::Security;
public ref class MyClass1
{
public:
MyClass1( int i ){}
};
int main()
{
try
{
Type^ myType = MyClass1::typeid;
array<Type^>^types = gcnew array<Type^>(1);
types[ 0 ] = int::typeid;
// Get the public instance constructor that takes an integer parameter.
ConstructorInfo^ constructorInfoObj = myType->GetConstructor( static_cast<BindingFlags>(BindingFlags::Instance | BindingFlags::Public), nullptr, CallingConventions::HasThis, types, nullptr );
if ( constructorInfoObj != nullptr )
{
Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is: " );
Console::WriteLine( constructorInfoObj );
}
else
{
Console::WriteLine( "The constructor of MyClass1 that is a public instance method and takes an integer as a parameter is not available." );
}
}
catch ( ArgumentNullException^ e )
{
Console::WriteLine( "ArgumentNullException: {0}", e->Message );
}
catch ( ArgumentException^ e )
{
Console::WriteLine( "ArgumentException: {0}", e->Message );
}
catch ( SecurityException^ e )
{
Console::WriteLine( "SecurityException: {0}", e->Message );
}
catch ( Exception^ e )
{
Console::WriteLine( "Exception: {0}", e->Message );
}
}
using System;
using System.Reflection;
using System.Security;
public class MyClass3
{
public MyClass3(int i) { }
public static void Main()
{
try
{
Type myType = typeof(MyClass3);
Type[] types = new Type[1];
types[0] = typeof(int);
// Get the public instance constructor that takes an integer parameter.
ConstructorInfo constructorInfoObj = myType.GetConstructor(
BindingFlags.Instance | BindingFlags.Public, null,
CallingConventions.HasThis, types, null);
if (constructorInfoObj != null)
{
Console.WriteLine("The constructor of MyClass3 that is a public " +
"instance method and takes an integer as a parameter is: ");
Console.WriteLine(constructorInfoObj.ToString());
}
else
{
Console.WriteLine("The constructor of MyClass3 that is a public instance " +
"method and takes an integer as a parameter is not available.");
}
}
catch (ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException: " + e.Message);
}
catch (ArgumentException e)
{
Console.WriteLine("ArgumentException: " + e.Message);
}
catch (SecurityException e)
{
Console.WriteLine("SecurityException: " + e.Message);
}
catch (Exception e)
{
Console.WriteLine("Exception: " + e.Message);
}
}
}
Public Class MyClass1
Public Sub New(ByVal i As Integer)
End Sub
Public Shared Sub Main()
Try
Dim myType As Type = GetType(MyClass1)
Dim types(0) As Type
types(0) = GetType(Integer)
' Get the public instance constructor that takes an integer parameter.
Dim constructorInfoObj As ConstructorInfo = _
myType.GetConstructor(BindingFlags.Instance Or _
BindingFlags.Public, Nothing, _
CallingConventions.HasThis, types, Nothing)
If Not (constructorInfoObj Is Nothing) Then
Console.WriteLine("The constructor of MyClass1 that " + _
"is a public instance method and takes an " + _
"integer as a parameter is: ")
Console.WriteLine(constructorInfoObj.ToString())
Else
Console.WriteLine("The constructor MyClass1 that " + _
"is a public instance method and takes an " + _
"integer as a parameter is not available.")
End If
Catch e As ArgumentNullException
Console.WriteLine("ArgumentNullException: " + e.Message)
Catch e As ArgumentException
Console.WriteLine("ArgumentException: " + e.Message)
Catch e As SecurityException
Console.WriteLine("SecurityException: " + e.Message)
Catch e As Exception
Console.WriteLine("Exception: " + e.Message)
End Try
End Sub
End Class
ネイティブ呼び出し規則は、コンパイルされたメソッドに渡される引数の順序とレイアウトを制御する規則のセットです。 また、戻り値を渡す方法、引数に使用するレジスタ、呼び出されたメソッドまたは呼び出し元のメソッドがスタックから引数を削除するかどうかも制御します。
製品 | バージョン |
---|---|
.NET | Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1 |
UWP | 10.0 |
.NET に関するフィードバック
.NET はオープンソース プロジェクトです。 フィードバックを提供するにはリンクを選択します。