本文整理匯總了C#中System.Runtime.InteropServices.CallingConvention枚舉的典型用法代碼示例。如果您正苦於以下問題:C# CallingConvention枚舉的具體用法?C# CallingConvention怎麽用?C# CallingConvention使用的例子?那麽, 這裏精選的枚舉代碼示例或許可以為您提供幫助。
在下文中一共展示了CallingConvention枚舉的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: printf
//引入命名空間
using System;
using System.Runtime.InteropServices;
internal static class NativeMethods
{
// C# doesn't support varargs so all arguments must be explicitly defined.
// CallingConvention.Cdecl must be used since the stack is
// cleaned up by the caller.
// int printf( const char *format [, argument]... )
[DllImport("msvcrt.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
internal static extern int printf(String format, int i, double d);
[DllImport("msvcrt.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
internal static extern int printf(String format, int i, String s);
}
public class App
{
public static void Main()
{
NativeMethods.printf("\nPrint params: %i %f", 99, 99.99);
NativeMethods.printf("\nPrint params: %i %s", 99, "abcd");
}
}