首页 > 其他 > 详细

2.0 - Exercise of Basic Statements

时间:2015-03-24 06:51:26      阅读:239      评论:0      收藏:0      [点我收藏+]

After I coded HelloWorld last week, I‘m going to update some codes using basic statements of C# this time.

  • Variables(Easy! So no more explanation here ~)

技术分享

  • Enumerations

Remember to cast the enumerated constant, explicitly, to its underlying type(int), when the value of it is wanted. I tried following codes to see the different output.

(codes)

技术分享

(output)

 技术分享

  • Branching Statements - Switch

In this case, keep in mind that, add break; at the end of each case. Also, maybe it‘s not a good choice to use goto statement.

(Simple Switch exercise)

技术分享

As for the reason I underline the statement above, when I first typed that short statement, I missed the space between case and 2; (just like case2;), then, of course, it doesn‘t work. Maybe it seems foolish, but being careful never hurts! By the way, when there is nothing special to do in a case like case2;, it‘s ok to omit  break;.

(Here comes the output)

技术分享

  • Iteration Statements - Foreach

(codes)

技术分享

I think it‘s quite easy when you understand how it works.

(I got the output after I‘d assigned "Still Hello World" to args[].)

技术分享

 

ENDing Word:

This time, I post statements either new or a little more important (in my opinion ~), though, they look simple, once again, being careful never hurts!

-----------ENDs & To Be Continued

(Ah! I almost forgot to refer that I Finally make my Visual Studio 2013 Pro with update 4 work! CONGRATULATION to me then~)

2.0 - Exercise of Basic Statements

原文:http://www.cnblogs.com/lyli/p/4361625.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!