Jon Jagger
Table of Contents 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 Notes DownloadECMA-334 C# Language Specificationpreviousnextprevious at this levelnext at this level 17 Classesprevious at this levelnext at this level 17.5 Methodsprevious at this levelnext at this level 17.5.7 External methods Paragraph 11 When a method declaration includes an extern modifier, the method is said to be an external method. 2 External methods are implemented externally, typically using a language other than C#. 3 Because an external method declaration provides no actual implementation, the method-body of an external method simply consists of a semicolon. Paragraph 21 The mechanism by which linkage to an external method is achieved, is implementation-defined. [Example: The following example demonstrates the use of the extern modifier in combination with a DllImport attribute that specifies the name of the external library in which the method is implemented:
using System.Text;  
using System.Security.Permissions;  
using System.Runtime.InteropServices;  
class Path  
   [DllImport("kernel32", SetLastError=true)]  
   static extern bool CreateDirectory(string name, SecurityAttribute sa);  
   [DllImport("kernel32", SetLastError=true)]  
   static extern bool RemoveDirectory(string name);  
   [DllImport("kernel32", SetLastError=true)]  
   static extern int GetCurrentDirectory(int bufSize, StringBuilder buf);  
   [DllImport("kernel32", SetLastError=true)]  
   static extern bool SetCurrentDirectory(string name);  
end example]
{ JSL }
Jagger Software Ltd
Company # 4070126
VAT # 762 5213 42
Valid HTML 4.01Valid CSS