?? c#+
字號:
ajaxRead(getRecFileName(urlRec),0);
} =09
=09
function BuildRecComment(){
=
Dottext.Web.UI.Controls.RecentComments.BuildComments(urlRec,buildRecCom_C=
allback);
}
=09
function UpdateView(message){
updateObj('comRecText', message);
}
//-->
</SCRIPT>
<BR><BR></DIV>
<DIV id=3Dmain>
<DIV class=3DTag>
<SCRIPT language=3Djavascript =
src=3D"http://tag.csdn.net/urltag.aspx"></SCRIPT>
<DIV style=3D"CLEAR: both"></DIV></DIV>
<SCRIPT>function =
StorePage(){d=3Ddocument;t=3Dd.selection?(d.selection.type!=3D'None'?d.se=
lection.createRange().text:''):(d.getSelection?d.getSelection():'');void(=
keyit=3Dwindow.open('http://www.365key.com/storeit.aspx?t=3D'+escape(d.ti=
tle)+'&u=3D'+escape(d.location.href)+'&c=3D'+escape(t),'keyit','scrollbar=
s=3Dno,width=3D475,height=3D575,left=3D75,top=3D20,status=3Dno,resizable=3D=
yes'));keyit.focus();}</SCRIPT>
<DIV class=3Dpost id=3Darticle>
<DIV class=3DpostTitle><A=20
href=3D"http://blog.csdn.net/mqt_2003/archive/2006/05/15/740185.aspx"><IM=
G=20
height=3D13 src=3D"http://blog.csdn.net/images/authorship.gif" =
width=3D15=20
border=3D0> C#=E8=8B=A5=E5=B9=B2=E7=9F=A5=E8=AF=86=E7=82=B9=E7=9A=84=
=E7=9B=B8=E5=85=B3=E5=B0=8F=E7=A8=8B=E5=BA=8F=EF=BC=88=E8=80=83=E4=B8=8B=E6=
=9D=A5=E7=9B=B4=E6=8E=A5=E8=BF=90=E8=A1=8C=EF=BC=8C=E4=BB=8E=E7=A8=8B=E5=BA=
=8F=E5=AD=A6=E4=B9=A0=E7=9F=A5=E8=AF=86=E7=82=B9=EF=BC=89</A></DIV>
<DIV class=3DpostText>
<P> &nbs=
p;  =
; =
&=
nbsp; &n=
bsp; &nb=
sp;=20
<FONT=20
size=3D4><STRONG>C#=E8=8B=A5=E5=B9=B2=E7=9F=A5=E8=AF=86=E7=82=B9=E7=9A=84=
=E5=B0=8F=E7=A8=8B=E5=BA=8F<BR></STRONG></FONT> =E3=80=80=E3=80=80=E3=
=80=80=E3=80=80=E3=80=80 &=
nbsp; &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
&=
nbsp; =20
<FONT=20
size=3D2>=E4=BD=9C=E8=80=85=EF=BC=9A=EF=BC=88ECNU=EF=BC=89=E5=AD=9F=E5=BA=
=86=E6=B6=9B<BR></FONT> &n=
bsp; &nb=
sp; &nbs=
p;  =
; =
&=
nbsp; &n=
bsp; &nb=
sp; &nbs=
p;=20
Email: <A =
href=3D"mailto:mqt-2003@163.com">mqt-2003@163.com</A></P>
<P><FONT =
size=3D2><STRONG>=E6=B3=A8=EF=BC=9A</STRONG></FONT>=E4=B8=80=E4=B8=8B=E6=98=
=AF=E4=B8=AA=E4=BA=BA=E5=9C=A8=E7=BB=83=E4=B9=A0C#=E6=97=B6=E6=89=80=E4=BD=
=BF=E7=94=A8=E7=9A=84=E4=BE=8B=E5=AD=90=EF=BC=8C=E6=9C=89=E4=B8=80=E9=83=A8=
=E5=88=86=E6=98=AF=E8=87=AA=E5=B7=B1=E5=86=99=E7=9A=84=EF=BC=8C=E4=B8=80=E9=
=83=A8=E5=88=86=E6=9D=A5=E8=87=AA=E4=BA=8E=E3=80=8AC#=20
=E9=AB=98=E7=BA=A7=E7=BC=96=E7=A8=8B=E3=80=8B=EF=BC=8C=E7=89=B9=E6=AD=A4=E5=
=A3=B0=E6=98=8E=E3=80=82=E5=A6=82=E9=9C=80=E5=BC=95=E7=94=A8=EF=BC=8C=E8=AF=
=B7=E6=A0=87=E6=98=8E=E4=BD=9C=E8=80=85<BR><FONT size=3D2><STRONG>1:=20
try_catch_fianlly=E8=AF=AD=E6=B3=95</STRONG></FONT><BR>using System;</P>
<P>namespace Wrox.ProCSharp.AdvancedCSharp<BR>{<BR> =
public=20
class MainEntryPoint<BR> =20
{<BR> public static void=20
Main()<BR> =20
{<BR> =
string=20
userInput;<BR>  =
; =20
while=20
(true)<BR> &nb=
sp;=20
{<BR> &n=
bsp; =20
try<BR> =
=20
{<BR> &n=
bsp; =20
Console.Write("Input a number between 0 and 5 " + "(or just hit return =
to=20
exit)>=20
");<BR> =
=20
userInput =3D=20
Console.ReadLine();<BR> &n=
bsp; =20
if (userInput =3D=3D=20
"")<BR> =
=
break;<BR> &nb=
sp; =20
int index =3D=20
Convert.ToInt32(userInput);<BR> =
=
if (index < 0 || index >=20
5)<BR> &=
nbsp; =20
throw new IndexOutOfRangeException("You typed in " +=20
userInput);<BR> &nbs=
p; =20
Console.WriteLine("Your number was " +=20
index);<BR> &n=
bsp; =20
}<BR> &n=
bsp; =20
catch (IndexOutOfRangeException=20
e)<BR> &=
nbsp; =20
{<BR> &n=
bsp; =20
Console.WriteLine("Exception: " +"Number should be between 0 and 5. " +=20
e.Message);<BR> &nbs=
p; =20
}<BR> &n=
bsp; =20
catch (Exception=20
e)<BR> &=
nbsp; =20
{<BR> &n=
bsp; =20
Console.WriteLine("An exception was thrown. Message was: " +=20
e.Message);<BR> &nbs=
p; =20
}<BR> &n=
bsp; =20
catch<BR> &nbs=
p; =20
{<BR> &n=
bsp; =20
Console.WriteLine("Some other exception has=20
occurred");<BR> &nbs=
p; =20
}<BR> &n=
bsp; =20
finally<BR> &n=
bsp; =20
{<BR> &n=
bsp; =20
Console.WriteLine("Thank=20
you");<BR> &nb=
sp; =20
}<BR> =20
}<BR> }<BR> =20
}<BR>}<BR><FONT =
size=3D2><STRONG>2=EF=BC=9A=E4=BB=A3=E8=A1=A8=EF=BC=88delegate=EF=BC=89=20
<BR></STRONG></FONT>=E6=B3=A8=E6=84=8F=EF=BC=8C=E8=BF=99=E4=B8=A4=E7=A7=8D=
=E7=9A=84=E8=BE=93=E5=87=BA=E7=BB=93=E6=9E=9C=E6=98=AF=E4=B8=8D=E5=90=8C=E7=
=9A=84=EF=BC=8C=E5=A4=A7=E5=AE=B6=E5=8F=AF=E4=BB=A5=E7=9B=B4=E6=8E=A5=E5=8E=
=BB=E8=BF=90=E8=A1=8C=E4=B8=80=E4=B8=8B=EF=BC=8C=E7=9C=8B=E7=9C=8B=EF=BC=9A=
<BR>(1)=E5=BD=A2=E5=BC=8F1<BR>using=20
System;</P>
<P>namespace Wrox.ProCSharp.AdvancedCSharp<BR>{<BR> delegate double =
DoubleOp(double x);</P>
<P> class MainEntryPoint<BR> {<BR> static void=20
Main()<BR> {<BR> /***************************=
***************************************************<BR> =
=20
* * <BR> *=20
=E4=BB=A3=E8=A1=A8=E6=95=B0=E7=BB=84=EF=BC=8C=E6=B3=A8=E6=84=8F=E5=92=8C=E2=
=80=9C+=E2=80=9D=E7=9A=84=E5=BD=A2=E5=BC=8F=E5=8C=BA=E5=88=AB<BR> &n=
bsp; * Console.WriteLine("Using=20
operations[{0}]:",=20
i);<BR> ProcessAndDisplayNumber(operations[i],=20
2.0);<BR> ProcessAndDisplayNumber(operations[i],=20
7.94);<BR> ProcessAndDisplayNumber(operations[i], =
1.414);<BR> * <BR> *=20
*************************************************************************=
****/<BR> DoubleOp=20
[] operations =3D <BR> {<BR> new =
DoubleOp(MathsOperations.MultiplyByTwo),<BR> new=20
DoubleOp(MathsOperations.Square)<BR> };</P>
<P> for (int i=3D0 ; i<operations.Length ;=20
i++)<BR> {<BR> Console.WriteLine(=
"Using=20
operations[{0}]:",=20
i);<BR> ProcessAndDisplayNumber(operations[i],=20
2.0);<BR> ProcessAndDisplayNumber(operations[i],=20
7.94);<BR> ProcessAndDisplayNumber(operations[i], =
1.414);<BR> Console.WriteLine();<BR> &n=
bsp; Console.ReadLine();<BR> }<BR> }</P>=
<P> static void ProcessAndDisplayNumber(DoubleOp action, =
double=20
value)<BR> {<BR> double result =3D=20
action(value);<BR> Console.WriteLine("Value is {0}, =
result of=20
operation is {1}", value, result);<BR> }<BR> }</P>
<P> class MathsOperations<BR> {<BR> public static =
double=20
MultiplyByTwo(double value)<BR> {<BR> return =
value*2;<BR> }</P>
<P> public static double Square(double=20
value)<BR> {<BR> return=20
value*value;<BR> }<BR> }<BR>}<BR>(2)=E5=BD=A2=E5=BC=8F2<B=
R>using System;</P>
<P>namespace Wrox.ProCSharp.AdvancedCSharp<BR>{<BR> delegate void=20
DoubleOp(double value);</P>
<P> class MainEntryPoint<BR> {<BR> static void=20
Main()<BR> {<BR> <BR> /*****=
************************************************************************<=
BR> =20
* <BR> * <BR> * DoubleOp operations =
=3D new=20
DoubleOp(MathsOperations.MultiplyByTwo);<BR>  =
;=20
operations +=3D new=20
DoubleOp(MathsOperations.Square);<BR> =20
operations+=3Dnew DoubleOp(MathsOperations.www);<BR> * =
=E6=B3=A8=E6=84=8F=E4=BB=A3=E8=A1=A8=E2=80=9C+=E2=80=9D=E7=9A=84=E4=BD=9C=
=E7=94=A8<BR> * <BR> *=20
<BR> * <BR> *=20
*************************************************************************=
***/<BR> DoubleOp=20
operations =3D new=20
DoubleOp(MathsOperations.MultiplyByTwo);<BR> operations =
+=3D new=20
DoubleOp(MathsOperations.Square);<BR> operations+=3Dnew =
DoubleOp(MathsOperations.www);</P>
<P> ProcessAndDisplayNumber(operations,=20
2.0);<BR> ProcessAndDisplayNumber(operations,=20
7.94);<BR> ProcessAndDisplayNumber(operations,=20
1.414);<BR> Console.WriteLine();<BR> Co=
nsole.ReadLine();<BR> }</P>
<P> static void ProcessAndDisplayNumber(DoubleOp action, =
double=20
value)<BR> {<BR> Console.WriteLine("\nProcess=
AndDisplayNumber=20
called with value =3D " +=20
value);<BR> action(value);<BR> <BR>&nbs=
p; }<BR> }</P>
<P> class MathsOperations<BR> {<BR> public static =
void=20
MultiplyByTwo(double value)<BR> {<BR> double =
result=20
=3D value*2;<BR> Console.WriteLine("Multiplying by 2: =
{0} gives=20
{1}", value, result);<BR> }</P>
<P> public static void Square(double=20
value)<BR> {<BR> double result =3D=20
value*value;<BR> Console.WriteLine("Squaring: {0} gives =
{1}",=20
value, result);<BR> }<BR> public static void =
www(double=20
value)<BR> {<BR> Console.WriteLine("ddddddddd=
dddd");<BR> }<BR>&nb
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -