C # External methods

Source: Internet
Author: User

The Using system;using system.runtime.interopservices;using system.text;/* * External method is a method that is not implemented in a declaration, and is often written in a programming language other than C #.  * 1, marked with the extern modifier, is not implemented in the declaration of the class, its implementation is replaced by a semicolon  * 2, the Declaration and the implementation of the connection is dependent on the implementation. Often use the DllImport feature to complete  */namespace externmethod{    class myclass    {        [ DllImport ("kernel32", Setlasterror=true)]        public static  extern int GetCurrentDirectory (int a,stringbuilder b);   }    class program    {        static void M Ain (string[] args)         {            const int maxdirlength = 250;&nbs P           StringBuilder sb = new StringBuilder ();            SB. Length = maxdirlength;            myclass.getcurrentdirectory (maxdirlength, SB);  & nbsp         Console.WriteLine (SB);            CoNsole. ReadKey ();       }   }

C # External methods

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.