CallingConventions Enumeration
.NET Framework 2.0
Defines the valid calling conventions for an enumeration.
Assembly: mscorlib (in mscorlib.dll)
This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.
Namespace: System.ReflectionAssembly: mscorlib (in mscorlib.dll)
[SerializableAttribute] [FlagsAttribute] [ComVisibleAttribute(true)] public enum CallingConventions
/** @attribute SerializableAttribute() */ /** @attribute FlagsAttribute() */ /** @attribute ComVisibleAttribute(true) */ public enum CallingConventions
SerializableAttribute FlagsAttribute ComVisibleAttribute(true) public enum CallingConventions
Member name | Description | |
---|---|---|
![]() | Any | Specifies that either the Standard or the VarArgs calling convention may be used. |
![]() | ExplicitThis | Specifies that the signature is a function-pointer signature, representing a call to an instance or virtual method (not a static method). If ExplicitThis is set, HasThis must also be set. The first argument passed to the called method is still a this pointer, but the type of the first argument is now unknown. Therefore, a token that describes the type (or class) of the this pointer is explicitly stored into its metadata signature. |
![]() | HasThis | Specifies an instance or virtual method (not a static method). At run-time, the called method is passed a pointer to the target object as its first argument (the this pointer). The signature stored in metadata does not include the type of this first argument, because the method is known and its owner class can be discovered from metadata. |
![]() | Standard | Specifies the default calling convention as determined by the common language runtime. Use this calling convention for static methods. For instance or virtual methods use HasThis. |
![]() | VarArgs | Specifies the calling convention for methods with variable arguments. |
using System; using System.Reflection; using System.Security; public class MyClass1 { public MyClass1(int i){} public static void Main() { try { Type myType = typeof(MyClass1); 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 MyClass1 that is a public " + "instance method and takes an integer as a parameter is: "); Console.WriteLine(constructorInfoObj.ToString()); } 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: " + 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); } } }
import System.*; import System.Reflection.*; import System.Security.*; public class MyClass1 { public MyClass1(int i) { } //MyClass1 public static void main(String[] args) { try { Type myType = MyClass1.class.ToType(); Type types[] = new Type[1]; types.set_Item(0, int.class.ToType()); // 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 MyClass1 that is a public " + "instance method and takes an integer as a parameter is: "); Console.WriteLine(constructorInfoObj.ToString()); } 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: " + e.get_Message()); } catch (ArgumentException e) { Console.WriteLine("ArgumentException: " + e.get_Message()); } catch (SecurityException e) { Console.WriteLine("SecurityException: " + e.get_Message()); } catch (System.Exception e) { Console.WriteLine("Exception: " + e.get_Message()); } } //main } //MyClass1
Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.
Show: