# Looping Statement vs Switch Statement

**URL:** <https://forum.uipath.com/t/looping-statement-vs-switch-statement/60367>\
**Category:** Help\
**Tags:** system, activities\
**Created:** [August 16, 2018, 5:40am UTC](https://forum.uipath.com/t/looping-statement-vs-switch-statement/60367 "2018-08-16T05:40:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![blaze.1411](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/blaze.1411/32/62464_2.png) [@blaze.1411](https://forum.uipath.com/u/blaze.1411)\
**Post date:** [August 16, 2018, 5:40am UTC](https://forum.uipath.com/t/looping-statement-vs-switch-statement/60367/1 "2018-08-16T05:40:28Z")

</div>

In Looping Statement(For Each / While) and Switch statement, Which activity has high performance and reduce processing time ?

---

<div class="post-metadata">

**Author:** ![Pankaj.Patil](https://avatars.discourse-cdn.com/v4/letter/p/8e7dd6/32.png) [@Pankaj.Patil](https://forum.uipath.com/u/Pankaj.Patil)\
**Post date:** [August 16, 2018, 6:14am UTC](https://forum.uipath.com/t/looping-statement-vs-switch-statement/60367/2 "2018-08-16T06:14:50Z")

</div>

Hello,

Looping Statements: For each and while traverse/iterate an each elements which are contained in array of elements.  
Switch Statement: Case statements are used to set different conditions. The break statement is used to break from the entire switch statement, once a condition is true.

Cheers,  
Pankaj

---

<div class="post-metadata">

**Author:** ![PrankurJoshi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prankurjoshi/32/37212_2.png) [@PrankurJoshi](https://forum.uipath.com/u/PrankurJoshi)\
**Post date:** [August 16, 2018, 6:50am UTC](https://forum.uipath.com/t/looping-statement-vs-switch-statement/60367/3 "2018-08-16T06:50:02Z")

</div>

See this for Switch -

> **[The Switch Activity](https://docs.uipath.com/studio/v2018.2/docs/the-switch-activity)**
>
> The Switch activity enables you to select one choice out of multiple, based on the value of a specified expression. By default, the Switch activity uses the integer argument, but you can change it from the Properties panel, from the TypeArgument...

and for loops -

> **[Control Flow](https://www.uipath.com/learning/video-tutorials/control-flow)**
>
> Control flow is a concept that refers to the order in which particular actions are taken. You can do this through activities, If Else statements and loops.

---

<div class="post-metadata">

**Author:** ![blaze.1411](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/blaze.1411/32/62464_2.png) [@blaze.1411](https://forum.uipath.com/u/blaze.1411)\
**Post date:** [August 16, 2018, 6:56am UTC](https://forum.uipath.com/t/looping-statement-vs-switch-statement/60367/4 "2018-08-16T06:56:46Z")

</div>

My question is **Which activity reduces process timing and improve performance during execution ?**?

---

<div class="post-metadata">

**Author:** ![PrankurJoshi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prankurjoshi/32/37212_2.png) [@PrankurJoshi](https://forum.uipath.com/u/PrankurJoshi)\
**Post date:** [August 16, 2018, 7:06am UTC](https://forum.uipath.com/t/looping-statement-vs-switch-statement/60367/5 "2018-08-16T07:06:03Z")

</div>

Both activities have different execution method and different results of implementation. You can compare If Statement and Switch statement or you can compare for each loop with While or Do while. There is no point of comparing Switch to Loops

---

<div class="post-metadata">

**Author:** ![blaze.1411](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/blaze.1411/32/62464_2.png) [@blaze.1411](https://forum.uipath.com/u/blaze.1411)\
**Post date:** [August 16, 2018, 12:32pm UTC](https://forum.uipath.com/t/looping-statement-vs-switch-statement/60367/6 "2018-08-16T12:32:01Z")

</div>

My scenario is “I have 10 records are 20 application, i have classified the records for each applications. Now, 10 records are missing for another 10 applications.”

I have to access only the 10 application for that 10 records , where i dont have records for other application.

Now, should i go with looping for all application or should i go with switch by if statement to go directly to the specfic app for the particular record?"

---

<div class="post-metadata">

**Author:** ![PrankurJoshi](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/prankurjoshi/32/37212_2.png) [@PrankurJoshi](https://forum.uipath.com/u/PrankurJoshi)\
**Post date:** [August 16, 2018, 12:39pm UTC](https://forum.uipath.com/t/looping-statement-vs-switch-statement/60367/7 "2018-08-16T12:39:39Z")

</div>

If you are sure that application would be 10 only and this number would not increase you should try Switch for any ifs and buts you should use loop
