While going through excellent Serge Lidin's IL book,
which shows that vararg unmanaged methods can be
easily called from IL. I tried finding  a way to call unmanaged
vararg methods from C#. The following
seems to be the way to do it (if need be, to interface
with legacy C methods):

class C
{
    [DllImport("msvcrt", CallingConvention = CallingConvention.Cdecl)]
        public static extern int printf(string s, __arglist);
    static void Main(string[] args)
    {
        printf("%d\r\n%s\r\n%.3f\r\n", __arglist(0, "hello", 0.123));
    }
}

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to