Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C# ¹Ø¼ü×ÖexternÓ÷¨

ÐÞÊηûÓÃÓÚÉùÃ÷ÔÚÍⲿʵÏֵķ½·¨¡£extern ÐÞÊηûµÄ³£¼ûÓ÷¨ÊÇÔÚʹÓà Interop ·þÎñµ÷Èë·Ç
ÍйܴúÂëʱÓë DllImport ÊôÐÔÒ»ÆðʹÓã»ÔÚÕâÖÖÇé¿öÏ£¬¸Ã·½·¨»¹±ØÐëÉùÃ÷Ϊ static£¬ÈçÏÂÃæµÄʾÀýËùʾ£º[DllImport("avifil32.dll")]
private static extern void AVIFileInit();
×¢Òâ
extern ¹Ø¼ü×Ö»¹¿ÉÒÔ¶¨ÒåÍⲿ³ÌÐò¼¯±ðÃû£¬Ê¹µÃ¿ÉÒÔ´Óµ¥¸ö³ÌÐò¼¯ÖÐÒýÓÃͬһ×é¼þµÄ²»Í¬°æ±¾¡£
½« abstract£¨C# ²Î¿¼£©ºÍ extern ÐÞÊηûÒ»ÆðʹÓÃÀ´ÐÞ¸Äͬһ³ÉÔ±ÊÇ´íÎóµÄ¡£Ê¹Óà extern ÐÞÊηûÒâζ×Å·½·¨ÔÚ C# ´úÂëµÄÍⲿʵÏÖ£¬¶øÊ¹
Óà abstract ÐÞÊηûÒâζ×ÅÔÚÀàÖÐδÌṩ·½·¨ÊµÏÖ¡£×¢Òâ
extern ¹Ø¼ü×ÖÔÚʹÓÃÉϱÈÔÚ C++ ÖÐÓиü¶àµÄÏÞÖÆ¡£ÈôÒªÓë C++ ¹Ø¼ü×Ö½øÐбȽϣ¬Çë²Î¼û C++ Language Reference ÖÐµÄ Using extern to
Specify Linkage¡£
ÔÚ¸ÃʾÀýÖУ¬³ÌÐò½ÓÊÕÀ´×ÔÓû§µÄ×Ö·û´®²¢½«¸Ã×Ö·û´®ÏÔʾÔÚÏûÏ¢¿òÖС£³ÌÐòʹÓÃ´Ó User32.dll ¿âµ¼ÈëµÄ MessageBox ·½·¨¡£
using System;
using System.Runtime.InteropServices;
class MainClass
{
   [DllImport("User32.dll")]
   public static extern int MessageBox(int h, string m, string c, int type);
   static int Main()
   {
      string myString;
      Console.Write("Enter your message: ");
      myString = Console.ReadLine();
      return MessageBox(0, myString, "My Message Box", 0);
   }
}
´ËʾÀýʹÓà C ³ÌÐò´´½¨Ò»¸ö DLL£¬ÔÚÏÂһʾÀýÖн«´Ó C# ³ÌÐòµ÷Óøà DLL¡£
// cmdll.c
// compile with: /LD
int __declspec(dllexport) SampleMethod(int i)
{
   return i*10;
}
¸ÃʾÀýʹÓÃÁ½¸öÎļþ CM.cs ºÍ Cmdll.c À´ËµÃ÷ extern¡£C ÎļþÊÇʾÀý 2 Öд´½¨µÄÍⲿ DLL£¬Ëü´Ó C# ³ÌÐòÄÚµ÷Óá£
// cm.cs
using System;
using System.Runtime.InteropServices;
public class MainClass
{
   [DllImport("Cmdll.dll")]
   public static extern int SampleMethod(int x);
   static void Main()
   {
      Console.WriteLine("SampleMethod() returns {0}.", SampleMethod(5));
   }
}
Êä³ö
SampleMethod() returns


Ïà¹ØÎĵµ£º

c#ÖÐbin,obj,propertiesÎļþ¼ÐµÄ×÷ÓÃ

¡¡¡¡Bin Ŀ¼ÓÃÀ´´æ·Å±àÒëµÄ½á¹û£¬binÊǶþ½øÖÆbinraryµÄÓ¢ÎÄËõд£¬ÒòΪ×î³õC±àÒëµÄ³ÌÐòÎļþ¶¼ÊǶþ½øÖÆÎļþ£¬ËüÓÐDebugºÍReleaseÁ½¸ö°æ±¾£¬·Ö±ð¶ÔÓ¦µÄÎļþ¼ÐΪbin/DebugºÍbin/Release£¬Õâ¸öÎļþ¼ÐÊÇĬÈϵÄÊä³ö·¾¶£¬ÎÒÃÇ¿ÉÒÔͨ¹ý£ºÏîÄ¿ÊôÐÔ—>ÅäÖÃÊôÐÔ—>Êä³ö·¾¶À´Ð޸ġ£
¡¡¡¡objÊÇobjectµÄËõд£¬ÓÃÓÚ´æ·Å ......

c# enmu ö¾ÙС½á(2)×Ô¼ºµÄ

ͨ¹ý·´É䣬µÃµ½Õë¶Ôijһö¾ÙÀàÐ͵ÄÃèÊö¡£
ö¾ÙµÄ¶¨ÒåÖмÓÈëÃèÊö
  using System;
using System.Collections;
namespace Ahnlab.ApplicationServices
{
public sealed partial class SysEnums
{


#region ϵͳ¹ÜÀíÄ£¿éµÄö¾ÙÐÅÏ¢
/// <summary>
/// ÔÚÏß²»Á¼Åâ³ ......

c#ʵÏÖÏÂÔØ´úÂëÊÕ¼¯

//TransmitFileʵÏÖÏÂÔØ
    protected void Button1_Click(object sender, EventArgs e)
    {
        /*
        Î¢ÈíΪResponse¶ÔÏóÌṩÁËÒ»¸öÐµķ½·¨TransmitFileÀ´½â¾öʹÓÃRespo ......

C#ɨÃè¼ÆËã»ú¶Ë¿Ú

using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Net.Sockets;
using System.Threading;
namespace PortScanner
{
class Program
{
¡¡//ÒÑɨÃè¶Ë¿ÚÊýÄ¿
¡¡internal static int scannedCount = 0;
¡¡//ÕýÔÚÔËÐеÄÏß³ÌÊýÄ¿
¡¡internal static int ru ......

c# Àà¿â

[SerializableAttribute]
[ComVisibleAttribute(true)]
[ClassInterfaceAttribute(ClassInterfaceType.AutoDual)]
public class Object
1 public virtual bool Equels (Object)
2 public static bool static Equels (Object,Object)
ĬÈÏʵÏÖΪ¶ÔÒýÓÃÀàÐÍʹÓÃÒýÓÃÏàµÈ£¬¶ÔÖµÀàÐÍʹÓöþ½øÖư´Î»ÏàµÈ¡£ÒýÓÃÏàµÈÐÔÊÇÖ¸½ø ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ