How to use Switch case in MSD axapta

How to use Switch case in axapta


The switch statement evaluates the variable used in the statement and instantly knows which case to continue to, as opposed to the if else if that has to evaluate from top to bottom until the if statement returns true.
Notice that you have to use the break statement at the bottom of each case. If not, it will continue to execute the next case as well.
The default statement can be used in a similar way as the else statement to say that if none of the other cases contained the correct value, jump to the default case instead.

 switch (carGroup)  
 {  
 case CarGroup::Economy :  
 info("Kia Picanto");  
 break;  
 case CarGroup::Compact :  
 info("Toyota Auris");  
 break;  
 case CarGroup::MidSize :  
 info("Toyota Rav4");  
 break;  
 case CarGroup::Luxury  
 info("BMW 520");  
 break;  
 default  
 info("Standard cars");  
 break;  
 }