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

static±äÁ¿Óëasp.net

ÔÚC#ÖУ¬static±äÁ¿±íʾ¸Ã±äÁ¿ÊôÓÚÀ࣬¶ø²»ÊÇÀàµÄʵÀý¡£¿ÉÒÔ˵ÊǸÃÀàµÄËùÓÐʵÀý¹²ÏíÒ»¸östatic±äÁ¿¡£
asp.netµÄÒ³Ãæ¾ÍÊÇÒ»¸öÀ࣬ÎÒÃÇ·ÃÎÊÒ»¸öÒ³Ãæ¡£¾Í»áÔÚ·þÎñÆ÷ÉÏʵÀý»¯Ò»¸ö¸ÃÀàµÄʵÀý£¬À´ÏìÓ¦ÎÒÃǵÄÇëÇó¡£
“ËùÓÐʵÀý¹²ÏíÒ»¸östatic±äÁ¿” Õâ¾ÍÒâζ×Å£¬ËùÓеĿͻ§¶Ë·ÃÎʵ½µÄasp.netÒ³ÃæÖÐstatic±äÁ¿¶¼ÊÇͬһ¸ö±äÁ¿¡£
ÓÉÓÚÎÒÃÇÿ´Î·ÃÎÊasp.netÒ³Ã涼ÊÇÒ»¸öȫеĶÔÏ󣬶ø²»ÊÇÎÒÃÇÉÏÒ»´Î·ÃÎʵĶÔÏó¡£ËùÒÔÉÏ´ÎÒ³Ãæ·ÃÎÊʱÎÒÃǶÔÒ³ÃæÖбäÁ¿µÄ¸Ä¶¯¶¼Ã»Óб£Áô¡£Óöµ½Õâ¸öÎÊÌâµÄʱºò£¬ºÜ¶à³õѧÕßµÄÖ±¾õ¾ÍÊǽ«Õâ¸ö±äÁ¿ÉêÃ÷Ϊstatic£¬×Ô¼ºÔÚ²âÊÔµÄʱºò·¢ÏÖ»¹ÕæµÄ±£ÁôסÁËÒ³ÃæµÄ״̬¡£ÇÔϲ֮ÓàûÓз¢ÏÖÕâÓÖÓÐÒýÈëÁËÁíÍâÒ»¸ö´íÎó¡£ÒòΪÄãÒªµÄÖ»ÊÇÒ³ÃæÄܱ£Áôס״̬£¬¶øÕâ¸ö״̬ÊÇÕë¶ÔÒ»¸ö¿Í»§¶ËµÄ£¨sessionµÄЧ¹û£©¡£¶øµÃµ½µÄ½á¹ûÊÇÖ»ÒªÒ»¸ö¿Í»§¶Ë¸Ä±äÁ˸ÃÖµËùÓеÄÆäËû¿Í»§¶Ë¶¼Êܵ½ÁËÓ°Ï죨ÈçͬApplicatinµÄЧ¹û£©¡£ÕâÖÖÇé¿öÏ£¬ÐèÒªµÄ¼«ÓпÉÄܾÍÊǸöViewState»òÕßÊÇSession¡£
ApplicationÓëstatic±äÁ¿
ApplicationÊÇͨ¹ýÒ»¸ö¼¯ºÏ±£´æËùÓеĶÔÏó¡£
Ç¿ÀàÐÍ:
ApplicationÖб£´æµÄÊÇobject,¶Ô¶ÔÏóµÄ±£´æºÍʹÓÃÐèÒª×÷cast¶¯×÷¡£¶ÔÓÚÖµÀàÐ͸üÐèÒªBox&UnBox¡£¶ÔÐÔÄܵÄÓ°Ïì½Ï´ó¡£
¶østatic±äÁ¿ÊÇÇ¿ÀàÐ͵ĶÔÏó¡£
Ïß³Ìͬ²½:
Application½«ËùÓеĶÔÏó·Åµ½Ò»¸ö¼¯ºÏ£¬ÕâÑù¶Ô·ÃÎʼ¯ºÏÖеÄÈκζÔÏ󶼻áËø¶¨Õâ¸ö¼¯ºÏ¡£
¼ÙÈçÓÐApplication["A"]¡¢Application["B"]¡¢Application["C"],ÓÐÏ̷߳ÃÎÊApplication["A"]ÆäËûÏ̲߳»ÄÜ·ÃÎÊApplication["B"] and Application["C"]¡£
¶østatic±äÁ¿£¬¿ÉÒÔ¸ù¾ÝËûÃǵÄ×÷Ó÷ֱð·ÅÔÚ²»Í¬µÄclassµ±ÖС£ÕâÑù¿ÉÒÔ²¢ÐзÃÎʲ»Í¬µÄstatic±äÁ¿£¬¶ø²»´æÔÚḬ̈߳²È«ÎÊÌâ¡£
ÓÑÇéÌáʾ£º
1. ¶Ôstatic±äÁ¿£¬×ölockʱ¡£¿ÉÒÔͨ¹ýlock(typeof(classname))À´Ëø¶¨¸Ã±äÁ¿ËùÔÚµÄÀàµÄÀàÐÍ£¬´ïµ½Ïß³Ìͬ²½µÄÄ¿µÄ¡£
2. ÓÉÓÚAplication,static memberÊÇÈ«¾Ö±äÁ¿,¶øÎÒÃÇÊÇÔÚ¶àÏ̷߳þÎñÆ÷»·¾³Ð´³ÌÐò£¬¶ÔËûÃǵÄʹÓÃÐèҪעÒâḬ̈߳²È«µÄÎÊÌâ¡£


Ïà¹ØÎĵµ£º

asp¡¢php¡¢asp.net¡¢jsp½éÉܼ°ÓÅȱµã±È½Ï

ÏÖÔÚÖ÷Á÷µÄÍøÕ¾¿ª·¢ÓïÑÔÎÞÍâºõasp¡¢php¡¢asp.net¡¢jspµÈ¡£
ÍøÒ³´Ó¿ªÊ¼¼òµ¥µÄhmtlµ½¸´ÔӵķþÎñÓïÑÔ£¬×ß¹ýÁË10¶à¸öÄêÍ·£¬¸÷ÖÖ¼¼Êõ²ã³ö²»Çµ¥¸öµÄÖ÷Á÷¼¼ÊõÒ²ÔÚ²»¶Ï·­Ðµİ汾£¬ÏÖÔÚ·ÖÎöϸ÷ÖÖÓïÑÔµÄÇø±ð¡¢ÓÅÊÆ¡¢ÁÓÊÆ¡¢¿ª·¢×¢ÒâÊÂÏ
HTML:µ±È»ÕâÊÇÍøÒ³×î»ù±¾µÄÓïÑÔ,ÿһ¸ö·þÎñÆ÷ÓïÑÔ¶¼ÐèÒªËüµÄÖ§³Ö,Ҫѧϰ,Õâ¸ö¿Ï¶¨ÊÇ¿ªÊ¼ ......

תÔØ ASP.NETÏÂÔØÎļþ´úÂë

ÈçºÎͨ¹ýASP.NETÀ´ÏÂÔØÎļþ£¬Õâ¸öÎÊÌâÎÒÃǾ­³£Óöµ½£¬°Ñ³£Óõķ½·¨×ܽᵽһÆð£¬Ñ§Ï°Ñ§Ï°¡£µ±ÎÒÃÇÒªÈÃÓû§ÏÂÔØÒ»¸öÎļþ£¬×î¼òµ¥µÄ·½Ê½ÊÇͨ¹ýResponse.RedirectÖ¸Á
Response.Redirect("test.doc")
Äú¿ÉÒÔ°ÑÉÏÃæÕâÐÐÖ¸Áî·ÅÔÚButtonµÄClickʼþµ±ÖУ¬µ±Óû§µã»÷°´Å¥Ö®ºó£¬ÍøÒ³¾Í»á±»×ªÖ·µ½¸Ãwordµµ£¬Ôì³ÉÏÂÔصÄЧ¹û¡£
µ«Ê ......

Asp.net»ñÈ¡ÉÏ´«Í¼Æ¬´óСµÄ³ß´ç£¡

1.²ÉÓÃÁ÷È¡µÃͼƬ´óС¡¡
Stream stream=file.PostedFile.InputStream;
System.Drawing.Image image=System.Drawing.Image.fromStream(stream);
Image.Width
Image.Height
2.ʹÓÃÎļþµÃµ½Í¼Æ¬´óС
System.Drawing.Image image=System.Drawing.Image.fromFile£¨Í¼Æ¬Â·¾¶£©
Image.Width
Image.Height ......

asp.netÖÐ×Ô¶¯¸½¼ÓÊý¾Ý¿âµÄ´úÂë


Ö±½Ó°ÑÊý¾Ý¿â·ÅÖÃApp_dataÎļþ¼ÐÖУ¬Ìí¼ÓÒ»¸öweb.configÅäÖÃÎļþÈ»ºóдÈçÏ´úÂë
<connectionStrings>
    <add name="users" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|Users.mdf;Integrated Security=True;User Instance=True" providerName="System.Data ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ