Ad Code

Responsive Advertisement

Operators in C#

Operators in C# 


Arithmetic –
+, -, *, /, %

Assignment –
=, +=, -=, *=, /=, %=

Comparison –
++, !+, <, <=, >, >=, is, as, like.

Concatenation –
+

Increment and decrement –
++ , --Logic –
&& , ||, ^

Conditional statement: - 

A block of code which gets executed basing on a condition is a conditional statement. There are two types
- Conditional branching.
- Conditional looping.

1. Conditional branching – 

This statement is also allow you to branch your code depending on whether certain condition were met or not. C# has two constructs for branching code, the if statement which allows you to test whether a specific condition is met and the switch statement which allows you to compare and expression with a no. of different values

2. Condition loop –

C# provides 4 different loops that allows you to execute a block of code repeatedly until the certain condition is mat those are –
  •  for loop
  •  while loop
  •  do …. while loop
  •  foreach loop
Every loop required three things in common
1. Initialization – which sets the starting point of loop.
2. Condition – which sets the end of a loop.
3. Iteration – this  tacks  you  to  the  next  level  of  the  loop,  either  in  forward  or  backward
direction.

FOR LOOP –


DO…… WHILE LOOP –

This is similar to while loop but for the first execution of the loop it doesn’t require any condition test. After completing the execution for one time then it checks for the condition to execute for next time.

FOREACH LOOP –    

     It is a special loop that has been design for the processing of arrays and collection.

Note- array is the set of similar type value, and the collection is the set of dissimilar type value.

JUMP STATEMENT – 

     C# provides a no. of statements that allow you to jump immediately to another line in a program w have four different jump statement support in

C# those are –
1. goto
2. break
3. continue
4. return

GOTO – 

IT  allows  you  to  jump  directly  to  another  specified  line  in  the  program indicated by a label which is an identifier followed by a colon (;).

BREAK –

It is used to exit from a case in a switch statement and also used to exit from for, foreach, while and do…..while loop. Which will switch the control to the statement immediately after and of the loop.

CONTINUE – 

This can be used only in the loop statements which will jumped the control to iteration part without executing the statements present after it.

RETURN – 

If a jump statement which can come out of a method or function if required in the mid of it execution as well as it is also capable to carry a value from the method or function outside.program using return -


Reactions

Post a Comment

0 Comments