| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | --- | 
					
						
							|  |  |  | title: Nested If Statement | 
					
						
							|  |  |  | --- | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # Nested If Statement
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-07 07:30:54 +05:30
										 |  |  | A Nested If Statement is used when a secondary point of validation or If statement is required inside the first If statement. | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-07 07:30:54 +05:30
										 |  |  | # Example
 | 
					
						
							|  |  |  | ```csharp | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | int Price = 100; | 
					
						
							|  |  |  | int Quantity = 20; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | if (Price == 100) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (Quantity == 20) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-12-07 07:30:54 +05:30
										 |  |  |     Console.WriteLine("The price of the item is 100, and we have 20 in quantity."); | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | ``` | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-12-07 07:30:54 +05:30
										 |  |  | Therefore, since we've predetermined Price and Quantity, the output would be: | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | 
 | 
					
						
							|  |  |  | ``` | 
					
						
							| 
									
										
										
										
											2018-12-07 07:30:54 +05:30
										 |  |  | The price of the item is 100, and we have 20 in quantity. | 
					
						
							| 
									
										
										
										
											2018-10-12 15:37:13 -04:00
										 |  |  | ``` |