C#UsingÓ÷¨
ÒýÓõØÖ·:http://www.cnblogs.com/heyaowen163/articles/1177909.html
C#¹Ø¼ü×ÖµÄÓ÷¨²»µ¥Ö»ÓÐÒ»ÖÖ·½·¨µÄ¡£ÏÖÔÚÎÒ×ܽáÁËÒ»ÏÂUsingºÍNewµÄÓ÷¨£¬Ë³±ã¹®¹ÌÏÂ×Ô¼ºµÄ֪ʶ¡£
Using
£¨1£©ÒýÓÃÃüÃû¿Õ¼ä
using×÷ΪÒýÈëÃüÃû¿Õ¼äÖ¸ÁîµÄÓ÷¨¹æÔòΪ£º
using Namespace;
ÔÚ.NET³ÌÐòÖУ¬×î³£¼ûµÄ´úÂëĪ¹ýÓÚÔÚ³ÌÐòÎļþµÄ¿ªÍ·ÒýÈëSystemÃüÃû¿Õ¼ä£¬ÆäÔÒòÔÚÓÚSystemÃüÃû¿Õ¼äÖзâ×°Á˺ܶà×î»ù±¾×î³£ÓõIJÙ×÷£¬ÏÂÃæµÄ´úÂë¶ÔÎÒÃÇÀ´Ëµ×îΪÊìϤ²»¹ý£º
using System;
ÕâÑù£¬ÎÒÃÇÔÚ³ÌÐòÖоͿÉÒÔÖ±½ÓʹÓÃÃüÃû¿Õ¼äÖеÄÀàÐÍ£¬¶ø²»±ØÖ¸¶¨ÏêϸµÄÀàÐÍÃû³Æ¡£usingÖ¸Áî¿ÉÒÔ·ÃÎÊǶÌ×ÃüÃû¿Õ¼ä¡£
¹ØÓÚ£ºÃüÃû¿Õ¼ä
ÃüÃû¿Õ¼äÊÇ.NET³ÌÐòÔÚÂß¼ÉϵÄ×éÖ¯½á¹¹£¬¶ø²¢·Çʵ¼ÊµÄÎïÀí½á¹¹£¬ÊÇÒ»ÖÖ±ÜÃâÀàÃû³åÍ»µÄ·½·¨£¬ÓÃÓÚ½«²»Í¬µÄÊý¾ÝÀàÐÍ×éºÏ»®·ÖµÄ·½Ê½¡£ÀýÈ磬ÔÚ.NETÖкܶàµÄ»ù±¾ÀàÐͶ¼Î»ÓÚSystemÃüÃû¿Õ¼ä£¬Êý¾Ý²Ù×÷ÀàÐÍλÓÚSystem.DataÃüÃû¿Õ¼ä£¬
£¨2£©´´½¨ÃüÃû¿Õ¼ä±ðÃû
usingΪÃüÃû¿Õ¼ä´´½¨±ðÃûµÄÓ÷¨¹æÔòΪ£º
using alias = namespace | type;
ÆäÖÐnamespace±íʾ´´½¨ÃüÃû¿Õ¼äµÄ±ðÃû£»¶øtype±íʾ´´½¨ÀàÐͱðÃû¡£ÀýÈ磬ÔÚ.NET OfficeÓ¦ÓÃÖУ¬³£³£»áÒýÈëMicrosoft.Office.Interop.Word.dll³ÌÐò¼¯£¬ÔÚÒýÈëÃüÃû¿Õ¼äʱΪÁ˱ÜÃâ·±ËöµÄÀàÐÍÊäÈ룬ÎÒÃÇͨ³£ÎªÆä´´½¨±ðÃûÈçÏ£º
using MSWord = Microsoft.Office.Interop.Word;
ÕâÑù£¬¾Í¿ÉÒÔÔÚ³ÌÐòÖÐÒÔMSWordÀ´´úÌæMicrosoft.Office.Interop.Wordǰ׺£¬Èç¹ûÒª´´½¨Application¶ÔÏó£¬Ôò¿ÉÒÔÊÇÕâÑù£¬
¶øÇÒ»¹ÓÐÒ»¸öºÃ´¦¾ÍÊÇ£¬ÔÚÒ»¸ö.CSÎļþÖÐÒýÈëÁ˲»Í¬µÄÃüÃû¿Õ¼äµ«ÊÇÏàͬµÄÀàÃûµÄʱºò£¬ÓñðÃû¾Í¿ÉÒÔ½â¾öÕâÎÊÌâÁË¡£
£¨3£©Ç¿ÖÆ×ÊÔ´ÇåÀí
ÓÃ;£ºÇåÀí·ÇÍйÜ×ÊÔ´£¬²»ÊÜGC¿ØÖƵÄ×ÊÔ´¡£Using½áÊøºó»áÒþʽµÄµ÷ÓÃDisposable·½·¨¡£
Ó÷¨:
using (Class1 c = new Class1())
Ïà¹ØÎĵµ£º
ÕâÁ½¸öÔÚÒ»°ãÇé¿öÏÂÊÇÏàµÈµÄ£¬µ«ÊÇϵͳ´¦Àí»úÖÆÉÏÈ´ÓÐËù²»Í¬¡£
""»áÔÚÄÚ´æÀï»®Ò»¿é³¤¶ÈΪ0µÄ´æ´¢¿Õ¼ä£¬¶øString.EmptyÄÚ´æ²¢²»ÎªËü·ÖÅä¿Õ¼ä£¬ËùÒÔÎÞÂÛÐÔÄÜ»¹ÊÇËÙ¶ÈÉÏString.Empty¶¼ÓÅÓÚ""¡£
Ôø¾¿´¹ýһƪÅжÏ×Ö·û´®¿ÕÖµµÄÐÔÄÜÎÄÕ£¬ÀÏÍâдµÄ¹úÈË·Ò룬ÎÄÕ´óÒâ ......
//»ñµÃºº×ÖµÄÇøλÂë
¡¡¡¡byte[] array = new byte[2];
¡¡¡¡array = System.Text.Encoding.Default.GetBytes("°¡");
int i1 = (short)(array[0] - ''\0'');
¡¡¡¡int i2 = (short)(array[1] - ''\0'');
//unicode½âÂ뷽ʽϵĺº×ÖÂë
¡¡¡¡array = System.Text.Encoding.Unicode.GetBytes("°¡");
¡¡¡¡i1 = (short)(arra ......
Õâ±¾Êé½²½â
C#
ÓïÑÔÊ®·ÖÏêϸ£¬ÎÒ½«ÆäÖеÄÖØÒªÄÚÈÝÕûÀí³ÉÌõ¿î£¬ÒÔ±¸Íü¡£
1.
ʼþÊÇÔÚÂú×ãij¸öÌض¨Ìõ¼þʱ·¢ÉúµÄ£¬´¥·¢
(raise)
ʼþµÄ¶ÔÏó³ÆΪ·¢²¼Õß
(publisher)
£¬¶ÔÕâ¸öʼþ½øÐÐÏìÓ¦µÄ¶ÔÏó³ÆΪ¶©ÔÄÕß
(subscriber)
¡£Ê¼þ´¦Àí³ÌÐòÊÇ×¢²áµ½Ê¼þµÄ·½·¨£¬¿ÉÔÚÈκÎÀà»òÕ߽ṹ ......
1.¾²Ì¬³ÉÔ±ºÍ·Ç¾²Ì¬³ÉÔ±µÄÇø±ð£¿
2.const ºÍ static readonly Çø±ð£¿
3.extern ÊÇʲôÒâ˼£¿
4.abstract ÊÇʲôÒâ˼£¿
5.internal ÐÞÊηûÆðʲô×÷Óã¿
6.sealed ÐÞÊηûÊǸÉʲôµÄ£¿
7.override ºÍ overload µÄÇø±ð£¿
8.ʲôÊÇË÷ÒýָʾÆ÷£¿
9.new ÐÞÊηûÊÇÆðʲô×÷Óã¿
10.this ¹Ø¼ü×ֵĺ¬Ò壿
11.¿ÉÒÔʹÓóéÏóº¯Ê ......
//TransmitFileʵÏÖÏÂÔØ
protected void Button1_Click(object sender, EventArgs e)
{
/*
΢ÈíΪResponse¶ÔÏóÌṩÁËÒ»¸öеķ½·¨TransmitFileÀ´½â¾öʹÓÃRespo ......