liyinglan

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

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~)

posted on 2015-03-24 03:19  liyinglan  阅读(152)  评论(1编辑  收藏  举报