- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use PowerShell Break statement with the Switch command?
In Switch command, when the single value passed and if it matches the condition then the loop gets automatically exited but when there are multiple values passed and if the value matches the first condition and if you want to terminate the loop then you can use the Break statement. An example is given below.
Example
Switch (3,5){ 1 {"This is One"} 2 {"This is Two"} 3 {"This is Three"; Break} 4 {"This is Four"} 5 {"This is Five"; Break} }
Output
This is Three
You can notice in the above output that second parameter 5 won’t be executed because the 3 has already been executed with the break statement.
Advertisements