home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / dotNETSDK / SETUP.EXE / netfxsd1.cab / FL_Printf_cs________.3643236F_FC70_11D3_A536_0090278A1BB8 < prev    next >
Encoding:
Text File  |  2001-08-27  |  908 b   |  35 lines

  1. // Copyright
  2. // Microsoft Corporation
  3. // All rights reserved
  4.  
  5. // Printf.cs
  6.  
  7. using System;
  8. using System.Runtime.InteropServices;
  9.  
  10. public class LibWrap
  11. {
  12.     // C# doesn't support varargs so all arguments must be explicitly defined
  13.     // CallingConvention.Cdecl must be used since the stack is cleaned up by the caller 
  14.     
  15.     // int printf( const char *format [, argument]... )
  16.     
  17.     [ DllImport( "msvcrt.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl )]
  18.     public static extern int printf( String format, int i, double d );    
  19.     
  20.     [ DllImport( "msvcrt.dll", CharSet=CharSet.Ansi, CallingConvention=CallingConvention.Cdecl )]
  21.     public static extern int printf( String format, int i, String s );    
  22.     
  23. }
  24.  
  25. public class App
  26. {
  27.     public static void Main()
  28.     {
  29.         LibWrap.printf( "\nPrint params: %i %f", 99, 99.99 );
  30.         LibWrap.printf( "\nPrint params: %i %s", 99, "abcd" );
  31.     }
  32. }
  33.  
  34.  
  35.