惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
小众软件
小众软件
GbyAI
GbyAI
B
Blog RSS Feed
月光博客
月光博客
A
About on SuperTechFans
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
Recent Announcements
Recent Announcements
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Vercel News
Vercel News
F
Fortinet All Blogs
Apple Machine Learning Research
Apple Machine Learning Research
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
雷峰网
雷峰网
Google DeepMind News
Google DeepMind News
MongoDB | Blog
MongoDB | Blog
Engineering at Meta
Engineering at Meta
aimingoo的专栏
aimingoo的专栏
博客园_首页
G
Google Developers Blog

博客园 - 许文

Sql server一些常见性能问题的总结 ASP.NET 开发规范 第八章 其它 ASP.NET 开发规范 第七章 控件命名 ASP.NET 开发规范 第五章 命名 ASP.NET 开发规范 第四章 声明 ASP.NET 开发规范 第三章 注释 ASP.NET 开发规范 第二章 代码外观 ASP.NET 开发规范 第一章 概述 ASP.NET 开发规范(目录) 多个子站点共用同一个Cookies验证 好久没有更新了,上传一个网站上通用的验证效果的函数吧。 信息系统集成项目管理的认识和体会 人月神话:软件界面交互和易用性改进总结 HotHeart写的Ajax类使用实例 ajax类使用过程出现的问题请教. 使用Nielsen的十条准则做WEB的启发式评估 写了一个Ajax的验证用户注册的函数, FileSystem对象常用的文件操作函数有哪些(转载) 您喜欢哪一种变量命名的规则
ASP.NET 开发规范 第六章 语句 - 许文
许文 · 2007-08-24 · via 博客园 - 许文

第六章 语句

6.1       每行一个语句

         每行最多包含一个语句。

             a++;       //推荐

             b--;       //推荐

a++; b--;  //不推荐

6.2 复合语句

复合语句是指包含"父语句{子语句;子语句;}"的语句,使用复合语句应遵循以下几点

            1 子语句要缩进。

2 左花括号“{” 在复合语句父语句的下一行并与之对齐,单独成行。

3 即使只有一条子语句要不要省略花括号“ {}”。 如

                  while  (d + =  s++)

                  {

                      n++;

                    }     

6.3 return 语句

        return语句中不使用括号除非它能使返回值更加清晰。如

              return;

              return myDisk.size();

              return (size ? size : defaultSize);

6.4 if if-elseif else-if 语句

        if if-elseif else-if 语句使用格式

            if (condition)

            {

                statements;

            }

            if (condition)

            {

                statements;

            }

            else{

                statements;

            }

            if (condition)

            {

                statements;

            }

            else if (condition)

            {

                statements;

            }

            else

            {

                statements;

            }

6.4   forforeach 语句

        for 语句使用格式

            for (initialization; condition; update)

            {

                statements;

            }

       空的 for 语句所有的操作都在initializationcondition update中实现使用格式

              for (initialization; condition; update);    // update user id       

       foreach 语句使用格式

              foreach (object obj in array)

              {

                  statements;

}

        注意 1在循环过程中不要修改循环计数器。

           2对每个空循环体给出确认性注释     

6.5 while 语句

        while 语句使用格式

            while (condition)

            {

                statements;

            }

         空的 while 语句使用格式   

              while (condition);               

6.7.         do - while 语句

         do - while 语句使用格式

              do

              {

                  statements;

              } while (condition);                

6.8.        switch - case 语句

         switch - case  语句使用格式

              switch (condition)

              {

                     case 1:

                         statements;

                         break;

                     case 2:

                         statements;

                         break;

                     default:

                         statements;

                         break;

                 }

           注意:

               1语句switch中的每个case各占一行

               2语句switch中的case按字母顺序排列。

               3为所有switch语句提供default分支。

               4所有的非空 case 语句必须用 break; 语句结束。 

6.9.   try - catch 语句      

          try - catch  语句使用格式

              try

              {

                  statements;

              }

              catch (ExceptionClass e)

              {

                  statements;

              }

              finally

              {

                statements;

              }   

6.10.        using 块语句      

         using 块语句使用格式

             using (object)

             {

                 statements;

             } 

6.11.        goto 语句      

  goto 语句使用格式

             goto Label1:

                 statements;

              Lable1:

                  statements;