c sharp conditional Statements

The if else Statements are used in C sharp to Evaluates  the given Condition if the condition is True then execute code in if block or if the the condition is false  then execute the else block code.For Example.







In the above program we are checking the UserLuckyNo if his lucky number less then 10 then the code in if Block will executed and will printed on screen "You are Really Lucky Person" .But If the UserLucky Number is greater then then the else if block code will executed  . and finally if the User did type any Number and just press Enter the Else block code will executed and will print on Screen that "You have to enter  Your lucky number".

c sharp user input console

Some time we need a user input for our programs . our program will wait for user input and then our program will evaluates user's input and then our Program can execute further.  For Example :


 Now the above Program will  take 2 Numbers from user and then will add user Numbers.
we will see in details  how the above program works indeed .

Getting First Number from User .

 First We Prompt User to Enter his/her First Number on Console Window. When user types a Number we have Declared a Integer Type x the User value will be stored in the Variable x . (Int.Parse) converts the User Typed value In 32-bit Signed Integer. (When ever a user Types on console Windows the Input are mostly consider as String in C Sharp so we have to convert the value to Integers in order to do some arithmetical operations ).
when the User Types his/her  First Value will be stored in  Int x .

Now for The 2nd value will type as follow.

 
Again the User's 2nd value will be stored in  in variable y . Now finally we will have to type as follow.

 
 We  Declare a Variable of Integer type  named sum and then we add value of x and value of y and then assign  the value to sum .finally when program run will take two values will added them and the sum will be printed on console window.


c sharp operators

C sharp have large  set of operators  we can define operator as "The symbols which defines which operation is performed in the expression ".
For Example:

                  int x = 2;
                 int y = 3;

               int sum = x + y;  
 // this an expression and the Operator ( + ) shows that the numerical values i.e will be added then will be assigned to  sum . 
    Console.WriteLine(sum);
   
 
     }
    }
}
   C# have the following  commonly used Operators.

Assignment Operators:
  
the Assignment Operators are used to assign Values to Variables in C sharp . 

for example :

if  int x =10  ; its mean that   we have a variable of Integer type and   x have  value which is assigned to x through assignment Operator (=).

Combined Assignment Operators in C sharp:

In C sharp like most other Languages we  can have combined assignment Operators  by combining the Ar-thematic operators and assignment operators.
For example :
we can have combined assignment operators as  int x +=2; which means that  int x =x+2; Some of other combined assignment Operators are as follow.

  •  *=   for example : int x =x*2;
  • /=   for example : int x= x/2;
  • %=   for example : int x = x % 2;
  • +=   for example : int x = x +2 ; 
Equality Operators:
the Equality Operators in C sharp make one variables value equal or not equal to other one.
int  x =2 ;  int y ;
if (x==1)
{
   //   you are equal to one 
and if the value is not equal to 1 then as follow 
if(x!=1)
{
   
   // do this you are not equal to one 
}

Logical AND  and Logical OR Operators:

 Logical AND and Logical OR Operators Evaluates Two Variables and then execute the program according to given conditions. 
Logical AND Operators are Represents by (&&) signs . Can be used in Program as follow.
















In the above program  the 2 variables namely x and y have their own values  in our condition we use logical AND operators which means that the x must be equal to 2 and y must be equal to 2 . its will evaluates the both conditions  must be return True.

Its the main Difference in Logical AND and Logical OR operators  in logical AND Operator the both conditions must be return True . if any one of them is not True then the  if statement will not executes. And will simply jumps to else Condition.  But in OR  Logical Condition Only 1 condition out of them should return True. as in following Program.


 













Now if we look at the above program we can see that y value is = 29  and in our logical condition. Is to print on Screen x =2 and y=3 if x==2  or y=2 meaning that any should be equal to 2 and the first x =2 so  it will print  x =2 and y=3 .

Sending SMS Via Windows Form Application Using any Android Smart Phone  Source Code  using System ; using System . C...