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

推荐订阅源

Microsoft Azure Blog
Microsoft Azure Blog
S
Securelist
V
Vulnerabilities – Threatpost
C
Cyber Attacks, Cyber Crime and Cyber Security
Schneier on Security
Schneier on Security
Cyberwarzone
Cyberwarzone
Simon Willison's Weblog
Simon Willison's Weblog
Hacker News - Newest:
Hacker News - Newest: "LLM"
P
Palo Alto Networks Blog
T
Troy Hunt's Blog
SecWiki News
SecWiki News
Security Archives - TechRepublic
Security Archives - TechRepublic
T
The Blog of Author Tim Ferriss
Project Zero
Project Zero
Microsoft Security Blog
Microsoft Security Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
J
Java Code Geeks
F
Full Disclosure
阮一峰的网络日志
阮一峰的网络日志
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Attack and Defense Labs
Attack and Defense Labs
Know Your Adversary
Know Your Adversary
WordPress大学
WordPress大学
PCI Perspectives
PCI Perspectives
N
News | PayPal Newsroom
The Last Watchdog
The Last Watchdog
酷 壳 – CoolShell
酷 壳 – CoolShell
P
Privacy & Cybersecurity Law Blog
P
Proofpoint News Feed
V
Visual Studio Blog
C
CERT Recently Published Vulnerability Notes
H
Help Net Security
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
云风的 BLOG
云风的 BLOG
月光博客
月光博客
T
The Exploit Database - CXSecurity.com
I
InfoQ
大猫的无限游戏
大猫的无限游戏
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
U
Unit 42
腾讯CDC
小众软件
小众软件
V2EX - 技术
V2EX - 技术
罗磊的独立博客
Cloudbric
Cloudbric
Recorded Future
Recorded Future
IT之家
IT之家
Google DeepMind News
Google DeepMind News
C
CXSECURITY Database RSS Feed - CXSecurity.com

博客园 - Forrest Gump

关于LINQ中数据库连接字符串的问题 项目开发经验-ASP.NET项目开发中的异常处理 关于模态窗口(showModalDialog)的专题【收藏】 C#面试题 C# 将数据导出到Excel汇总 关于Assembly.CreateInstance()与Activator.CreateInstance()方法 PowerDesigner概念设计模型(CDM)中的3种实体关系 C#基础概念二十五问 Microsoft .NET Pet Shop 4:将 ASP.NET 1.1 应用程序迁移到 2.0 用Inno Setup制作WEB程序安装包 冒泡法数组排序与 System.Array.Sort()排序性能比较 堆排序 (Heap sort) 合并排序法(Merge Sort) 希尔排序法 quick sort C#中一些很基础但有经常导致错误的一些概念 Enterprise Library Step By Step系列(十六):使用AppSetting Application Block Enterprise Library Step By Step系列(十五):配置应用程序块——设计篇 创建基于消息队列(MSMQ)的异步日志
关于switch的小技巧
Forrest Gump · 2008-01-21 · via 博客园 - Forrest Gump


switch中的case穿越

 1using System;
 2
 3class SwitchSample
 4{
 5    public static void Main()
 6    {
 7        Console.WriteLine("Please enter the letter:");
 8        string letter = Console.ReadLine();
 9
10        switch(letter)
11        {
12            case "a":
13            case "A":
14            case "b":
15            case "B":
16                Console.WriteLine("it's Ok");
17                break;
18            case "c":
19            case "C":
20            default:
21                Console.WriteLine("default!!!!!");
22                break;
23        }

24    }

25}

输入a
运行结果
it's ok

当case中放空语句的时候,流程控制会直接穿越这个case到下一个case,直到非空语句为止,所以上面的程序当我们输入a的时候,会直接穿越到16行执行。我们可以利用这个特点让多个条件执行同一个语句。

posted @ 2008-01-21 18:06  Forrest Gump  阅读(419)  评论(0)    收藏  举报

刷新页面返回顶部