c#:¶¨ÒåÌØÐÔ
c#±à³Ì»ù´¡Ö®¶þ£ºÌØÐÔ ÕâÀïµÄÌØÐÔÇø±ðÓÚÊôÐÔ£¬ËäÈ»msdnÖÐËƺõ²¢Ã»ÓÐÇø±ð¶þÕß¡£
ÊôÐÔ£ºÊÇÃæÏò¶ÔÏó±à³ÌµÄ»ù±¾¸ÅÄÌṩÁ˶Ô˽ÓÐ×ֶεķÃÎÊ·â×°£¬ÔÚC#ÖÐÒÔgetºÍset·ÃÎÊÆ÷·½·¨ÊµÏֶԿɶÁ¿ÉдÊôÐԵIJÙ×÷£¬ÌṩÁË°²È«ºÍÁé»îµÄÊý¾Ý·ÃÎÊ·â×°¡£
ÌØÐÔ£º¹«¹²ÓïÑÔÔËÐÐʱÔÊÐíÌí¼ÓÀàËƹؼü×ÖµÄÃèÊöÉùÃ÷£¬½Ð×öattributes, Ëü¶Ô³ÌÐòÖеÄÔªËؽøÐбê×¢£¬ÈçÀàÐÍ¡¢×ֶΡ¢·½·¨ºÍÊôÐԵȡ£AttributesºÍMicrosoft .NET FrameworkÎļþµÄÔªÊý¾Ý±£´æÔÚÒ»Æ𣬿ÉÒÔÓÃÀ´ÏòÔËÐÐʱÃèÊöÄãµÄ´úÂ룬»òÕßÔÚ³ÌÐòÔËÐеÄʱºòÓ°ÏìÓ¦ÓóÌÐòµÄÐÐΪ¡£±ÈÈç [Serializable]¡¢[Flags]¡¢[DllImport]¡¢[AttributeUsage]
ÎÒÃǼòµ¥µÄ×ܽáΪ£º¶¨ÖÆÌØÐÔattribute£¬±¾ÖÊÉÏÊÇÒ»¸öÀ࣬ÆäΪĿ±êÔªËØÌṩ¹ØÁª¸½¼ÓÐÅÏ¢£¬²¢ÔÚÔËÐÐÆÚÒÔ·´ÉäµÄ·½Ê½À´»ñÈ¡¸½¼ÓÐÅÏ¢¡£
ÎÒÀí½âµÄ¶¨ÖÆÌØÐÔ£¬¾ÍÊÇΪĿ±êÔªËØ£¬¿ÉÒÔÊÇÊý¾Ý¼¯¡¢Ä£¿é¡¢Àà¡¢ÊôÐÔ¡¢·½·¨¡¢ÉõÖÁº¯Êý²ÎÊýµÈ¼ÓÈ븽¼ÓÐÅÏ¢£¬ÀàËÆÓÚ×¢ÊÍ£¬µ«ÊÇ¿ÉÒÔÔÚÔËÐÐÆÚÒÔ·´ÉäµÄ·½Ê½»ñµÃ¡£¶¨ÖÆÌØÐÔÖ÷ÒªÓ¦ÓÃÔÚÐòÁл¯¡¢±àÒëÆ÷Ö¸Áî¡¢Éè¼ÆģʽµÈ·½Ãæ¡£
Ò»¡¢Í¨ÓùæÔò£º
1¡¢¶¨ÖÆÌØÐÔ¿ÉÒÔÓ¦ÓõÄÄ¿±êÔªËØ¿ÉÒÔΪ£º³ÌÐò¼¯(assembly)¡¢Ä£¿é(module)¡¢ÀàÐÍ(type)¡¢ÊôÐÔ(property)¡¢Ê¼þ(event)¡¢×Ö¶Î(field)¡¢·½·¨(method)¡¢²ÎÊý(param)¡¢·µ»ØÖµ(return)£¬Ó¦¸ÃÈ«ÁË¡£
2¡¢¶¨ÖÆÌØÐÔÒÔ[,]ÐÎʽչÏÖ£¬·ÅÔÚ½ô°¤×ŵÄÔªËØÉÏ£¬¶à¸öÌØÐÔ¿ÉÒÔÓ¦ÓÃÓÚͬһԪËØ£¬ÌØÐÔ¼äÒÔ¶ººÅ¸ô¿ª£¬ÒÔϱí´ï¹æÔòÓÐЧ£º[AttributeUsage][ Flags]¡¢[AttributeUsage, Flags]¡¢[Flags, AttibuteUsageAttribute]¡¢[AttributeUsage(), FlagesAttribute()]
3¡¢attibuteʵÀý£¬ÊÇÔÚ±àÒëÆÚ½øÐгõʼ»¯£¬¶ø²»ÊÇÔËÐÐÆÚ¡£
4¡¢C#ÔÊÐíÒÔÖ¸¶¨µÄǰ׺À´±íʾÌØÐÔËùÓ¦ÓõÄÄ¿±êÔªËØ£¬½¨ÒéÕâÑùÀ´´¦Àí£¬ÒòΪÏÔʽ´¦Àí¿ÉÒÔÏû³ý¿ÉÄÜ´øÀ´µÄ¶þÒåÐÔ¡£ÀýÈ磺
using System;
namespace Anytao.net
{
[assembly: MyAttribute(1)] //Ó¦ÓÃÓÚ³ÌÐò¼¯
[mod
Ïà¹ØÎĵµ£º
/**************************************************************************************************
* ×÷Õßwenwenhua
*
/* Program : A Simple Screen Saver
* File Name : ScreenSaver.cs
* Author : Tran Khanh Hien
......
Ë®ÏÉ»¨Êý£ºÒ»¸öÈýλÕûÊý¸÷λÊý×ÖµÄÁ¢·½ºÍµÈÓÚ¸ÃÊý±¾Éí¾Í³Æ¸ÃÊýΪˮÏÉ»¨Êý£¬Ë®ÏÉ»¨Êý¹²ÓÐ4¸ö£¬·Ö±ðΪ£º153¡¢370¡¢371¡¢407( ÀýÈ磺1^3 + 5^3 + 3^3 = 153 )¡£ÎÒдµÄ´úÂëÈçÏ£¬ÄãÓÐÆäËûµÄʵÏÖ´úÂëÒ²¿ÉÒÔ·¢±íÆÀÂÛ¡£
int i, m,n,k;
for (i = 100; i < 1000; i++)
{
//È¡µÃ°ÙλÊý
m = i / 100;
//È¡µ ......
Ê×ÏÈдһ¸öÒ³Ã棬ÉÏÃæÒª·ÅÒ»¸öButton
<html>
<head>
<title></title>
</head>
<body>
<input id="Button1" type="button" value="button" />
</body>
</html>
½«Æä±£´ ......
¹ØÓÚʹÓõ½ÁËÁ½¸öC#¹Ø¼ü×ÖthisºÍbase¡£
1£¬C# "this " keyword
Æä×÷ÓÃÒýÓÃÀàµÄµ±Ç°ÊµÀý£¬Æäʵ¿´ÁËÏÂÃæÕâ¸öÀý×ӾͺÃÀí½âÁË¡£
Ö÷ÒªÈý¸ö×÷Ó㺵±Ç°ÊµÀý¡¢²ÎÊý´«µÝºÍË÷ÒýÆ÷
1.1 µ±Ç°ÊµÀý
class Team
{
///³ÉÔ±±äÁ¿
private string name;
///¹¹Ô캯Êý
......
ίÍкÍʼþÔÚ .Net FrameworkÖеÄÓ¦Ó÷dz£¹ã·º£¬È»¶ø£¬½ÏºÃµØÀí½âίÍкÍʼþ¶ÔºÜ¶à½Ó´¥C#ʱ¼ä²»³¤µÄÈËÀ´Ëµ²¢²»ÈÝÒס£ËüÃǾÍÏñÊÇÒ»µÀ¼÷¶ù£¬¹ýÁËÕâ¸ö¼÷µÄÈË£¬¾õµÃÕæÊÇÌ«ÈÝÒ×ÁË£¬¶øûÓйýÈ¥µÄÈËÿ´Î¼ûµ½Î¯ÍкÍʼþ¾Í¾õµÃÐÄÀï±ð£¨bi裩µÃ»Å£¬»ìÉí²»×ÔÔÚ¡£±¾ÎÄÖУ¬ÎÒ½«Í¨¹ýÁ½¸ö·¶ÀýÓÉdzÈëÉîµØ½²ÊöʲôÊÇίÍС¢ÎªÊ²Ã´ÒªÊ¹Ó ......