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

C#ÃæÊÔ±ÊÊÔСÌùÊ¿ 2

¶ÔÓÚ¶à̬£¬»¹±ØÐèÌáÒ»¸öC#ÖеĹؼü×Ö£ºnew¡£Ç°ÃæÌáµ½£¬¶ÔÓÚvirtual·½·¨£¬JIT»áÈ·¶¨ÊµÀýµÄʵ¼ÊÀàÐÍÈ»ºó¾ö¶¨µ÷ÓÃʲô·½·¨¡£µ«ÊÇÈç¹ûÅÉÉúÀàÖÐnew¹Ø¼ü×ÖÐÞÊη½·¨£¬ÔòËüÏòCLR³ÎÇå´ËÅÉÉúÀàÖеķ½·¨Óë»ùÀàÖеķ½·¨ºÁÎÞ¹Øϵ£¬ÒÔÏ´úÂë×îÖÕµ÷ÓÃÊÇ»ùÀàµÄintroduce·½·¨£º
Code
class Program
{
    static void Main(string[] args)
     {
         Sample1.M1(new OrdinaryPeople("ZhangSan"));
         Sample1.M1(new Superman("Hancock"));
         Console.Read();
     }
}
class Sample1
{
    public static void M1(Person p)
     {
         p.Introdce();
     }
}
class Person
{
    protected string mName;
    public Person(string pName)
     {
        this.mName = pName;
     }
    public virtual void Introdce()
     {
         Console.WriteLine("Hello,I am " + this.mName);
     }
}
class OrdinaryPeople : Person
{
    public OrdinaryPeople(string pName)
         : base(pName)
     {
     }
    public new void Introdce()
     {
         Console.WriteLine("Hello,I am an ordinary person," + this.mName);
     }
}
class Superman : Person
{
    public Superman(string pName)
         : base(pName)
     {
     }
    public new void Introdce()
   &


Ïà¹ØÎĵµ£º

C#UsingÓ÷¨

ÒýÓõØÖ·:http://www.cnblogs.com/heyaowen163/articles/1177909.html
         C#¹Ø¼ü×ÖµÄÓ÷¨²»µ¥Ö»ÓÐÒ»ÖÖ·½·¨µÄ¡£ÏÖÔÚÎÒ×ܽáÁËÒ»ÏÂUsingºÍNewµÄÓ÷¨£¬Ë³±ã¹®¹ÌÏÂ×Ô¼ºµÄ֪ʶ¡£
Using
£¨1£©ÒýÓÃÃüÃû¿Õ¼ä
        
using× ......

C#Çå³ýÒ³Ã滺´æ

C#Çå³ýÒ³Ã滺´æ
    private void SetPageNoCache()
        {
            Response.Buffer = true;
            Response.ExpiresAbsolute = Sy ......

C# DllImportµÄÓ÷¨

´ó¼ÒÔÚʵ¼Ê¹¤×÷ѧϰC#µÄʱºò£¬¿ÉÄÜ»áÎÊ£ºÎªÊ²Ã´ÎÒÃÇҪΪһЩÒѾ­´æÔڵŦÄÜ£¨±ÈÈçWindowsÖеÄһЩ¹¦ÄÜ£¬C++ÖÐÒѾ­±àдºÃµÄһЩ·½·¨£©ÒªÖØбàд´úÂ룬C#ÓÐûÓз½·¨¿ÉÒÔÖ±½Ó¶¼ÓÃÕâЩԭ±¾ÒѾ­´æÔڵŦÄÜÄØ£¿´ð°¸Êǿ϶¨µÄ£¬´ó¼Ò¿ÉÒÔͨ¹ýC#ÖеÄDllImportÖ±½Óµ÷ÓÃÕâЩ¹¦ÄÜ¡£
DllImportËùÔÚµÄÃû×Ö¿Õ¼ä using System.Runtime.Inte ......

C# API ´óÈ«

C:\ProgramFiles\MicrosoftVisual Studio .NET\ FrameworkSDK\Samples\ Technologies\ Interop\PlatformInvoke\ WinAPIs\CSĿ¼ÏÂÓдóÁ¿µÄµ÷ÓÃAPIµÄÀý×Ó¡£
Ò»¡¢µ÷Óøñʽ
using System.Runtime.InteropServices; //ÒýÓôËÃû³Æ¿Õ¼ä£¬¼ò»¯ºóÃæµÄ´úÂë
//ʹÓÃDllImportAttributeÌØÐÔÀ´ÒýÈëapiº¯Êý£¬×¢ÒâÉùÃ÷µÄÊÇ¿Õ·½·¨£¬¼´·½· ......

C#ÃæÊÔ±ÊÊÔСÌùÊ¿ 1

ü   ref¡¢out¡¢Óëparams
Ó¦¸ÃÀ´ËµÕâÈý¸ö¹Ø¼üÔÚÒ»°ãµÄ±àÂë¹ý³ÌÖл¹Êǻ᲻ʱÉæ¼°µ½µÄ£¬ËùÒÔ²»Ëãʲô“ÀäƧ”µÄ¸ÅÄî¡£ÓйØÈý¸ö²ÎÊýÐÞÊηûµÄ½âÊÍÈçÏ£º
Ref£ºref¹Ø¼ü×ÖÈÃÒ»¸öÖµÀàÐ͵ÄÊäÈë²ÎÊý°´ÒýÓô«µÝ¡£Êµ¼ÊÉÏ£¬¶ÔÓÚÒýÓÃÀàÐ͵IJÎÊý£¬ÊÇ·ñʹÓÃref¹Ø¼ü×Ö£¬²î±ð΢ºõÆä΢¡£ÓÐÒ»¸öÀýÍâÊÇStringÀàÐ͵IJΠ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ