c# virtualÐ麯ÊýµÄnew¡¢overrideʵÏÖ
c#ÖлùÀࣨ¸¸ÀࣩÖеÄij·½·¨ÈôÏëÔÚÅÉÉúÀࣨ×ÓÀࣩÖб»ÖØд£¨override£©£¬±ØÐ뽫»ùÀàÖеķ½·¨¶¨ÒåΪvirtual£¬¼´Ð麯Êý¡£
ÈôÅÉÉúÀཫ·½·¨ÐÞÊÎΪnew£¬¼´ÓÐÒâÒþ²Ø»ùÀàÖеķ½·¨¡£
ÏÂÃæ¿´Ò»×é´úÂ룺
public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}
public class Son : Father
{
public void hand()
{
Console.WriteLine("Son.hand");
}
static void Main(string[] args)
{
Father son = new Son();
son.hand();
Console.ReadLine();
}
}
Êä³ö£ºFather.hand
¾¯¸æ£º“Son.hand()”½«Òþ²Ø¼Ì³ÐµÄ³ÉÔ±“Father.hand()”¡£ÈôҪʹµ±Ç°³ÉÔ±ÖØд¸ÃʵÏÖ£¬ÇëÌí¼Ó¹Ø¼ü×Ö override¡£·ñÔò£¬Ìí¼Ó¹Ø¼ü×Ö new¡£
public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}
public class Son : Father
{
public override void hand()
{
Console.WriteLine("Son.hand");
}
static void Main(string[] args)
{
Father son = new Son();
son.hand();
Console.ReadLine();
}
}
±àÒë´íÎ󣺓Son.hand()”: ¼Ì³Ð³ÉÔ±“Father.hand()”δ±»±ê¼ÇΪ virtual¡¢abstract »ò override£¬ÎÞ·¨½øÐÐÖØд¡£
public class Father
{
public virtual void hand()
{
Console.WriteLine("Father.hand");
}
}
public class Son : Father
{
public override void hand()
{
Console.WriteLine("Son.hand");
}
static void Main(string[] args)
{
Father son = new Son();
son.hand();
Console.ReadLine();
}
}
Êä³ö£ºSon.hand
ÎÞ¾¯¸æ¡£
public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}
public class Son : Father
{
public new void hand()
{
Console.WriteLine("Son.hand");
}
static void Main(string[] args)
{
Father son = new Son();
son.hand();
Ïà¹ØÎĵµ£º
ͨ³£ÎÒÃÇÔÚ³ÌÐòÖÐÐèÒªµ÷ÓÃWebServiceʱ£¬¶¼ÊÇͨ¹ý“Ìí¼ÓWebÒýÓÔ£¬ÈÃVS.NET»·¾³À´ÎªÎÒÃÇÉú³É·þÎñ´úÀí£¬È»ºóµ÷ÓöÔÓ¦µÄWeb·þÎñ¡£ÕâÑùÊÇʹ¹¤×÷¼òµ¥ÁË£¬µ«ÊÇÈ´ºÍÌṩWeb·þÎñµÄURL¡¢·½·¨Ãû¡¢²ÎÊý°ó¶¨ÔÚÒ»ÆðÁË£¬ÕâÊÇVS.NET×Ô¶¯ÎªÎÒÃÇÉú³ÉWeb·þÎñ´úÀíµÄÏÞÖÆ¡£Èç¹ûÄÄÒ»Ìì·¢²¼Web·þÎñµÄURL¸Ä±äÁË£¬ÔòÎÒÃÇÐèÒªÖØÐÂÈÃVS.NE ......
תÒåÐòÁÐ ×Ö·ûÃû³Æ Unicode ±àÂë
\' µ¥ÒýºÅ 0x0027
\" Ë«Òýº ......
ÀûÓÃWM_COPYDATAÔÚÓ¦ÓóÌÐò¼ä´«µÝÊý¾ÝºÜ¼òµ¥,¿ªÏúҲС
Ò»¡¢´«µÝÊý¾Ý²¿·Ö
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ThreeTorches
{
public struct Copydatastru ......
´ó¼ÒÔÚʵ¼Ê¹¤×÷ѧϰC#µÄʱºò£¬¿ÉÄÜ»áÎÊ£ºÎªÊ²Ã´ÎÒÃÇҪΪһЩÒѾ´æÔڵŦÄÜ£¨±ÈÈçWindowsÖеÄһЩ¹¦ÄÜ£¬C++ÖÐÒѾ±àдºÃµÄһЩ·½·¨£©ÒªÖØбàд´úÂ룬C#ÓÐûÓз½·¨¿ÉÒÔÖ±½Ó¶¼ÓÃÕâЩԱ¾ÒѾ´æÔڵŦÄÜÄØ£¿´ð°¸Êǿ϶¨µÄ£¬´ó¼Ò¿ÉÒÔͨ¹ýC#ÖеÄDllImportÖ±½Óµ÷ÓÃÕâЩ¹¦ÄÜ¡£
DllImportËùÔÚµÄÃû×Ö¿Õ¼ä using System.Runtime.Inte ......