Tuesday 16 March 2021

C# Concepts

 Q1)What is Difference between  For Loop and For-Each Loop in C#?

  • For loop iterates a statement or a block of statements repeatedly until a specified expression evaluates to false.
  •  For-each loop is used to iterate through the items in object collections, List generic collections or array list collections. 
  • Performance: For Loops are faster than For-each Loop. If we iterate array list or any collection with for loop and for-each loop then you will find time consumed by a for-each loop is much more than for loop so For loops are faster than For-each loop.
Q2) What is mean by Conditional statement? 
Ans: A block of code that gets executed basis on a condition is known as conditional Statement. These are of two types:
  •  Conditional Branching
  •  Conditional Looping.
Q3)What is mean by Conditional Branching? 
Ans: These statements allow us to branch our code depending on whether certain condition was met or not. C# has two constructs for branching code
  •  If 
  • Switch
Q4)What is mean by Conditional Looping?
Ans: C# provides three different loops that allows us to execute a block of code repeatedly until a certain condition is met, those are 
  • For Loop 
  • While Loop 
  • Do While Loop
 Every Loop requires three things in common. 
  1. Initialization: That sets the starting point of the loop. 
  2. Condition: That sets the ending point of the loop. 
  3. Iteration: Which takes you to the next level of the cycle either forward or backward direction.
Q5)

No comments:

Post a Comment