The operator in C#:-


It is used to perform an operation using Operand, C# Support all operators of C and C++.

Type of Operator:-

1) Unary Operator:-   It will work using Single Operand

1.1.1)  Increment|Decrement  :- ++,--

           Post  :-     ++,--  a++,a--  (first assignment then increment or decrements)

          Pre  :-        ++,--, ++a,--a  (First Increment Or Decrement Then assignment)


using System;

class Incr
{
    public static void Main()
    {
          int a=2,b;
          b=a++;   //assignment means
          Console.WriteLine("a="+a+" b="+b);
         

    }

}


2) Binary Operator:- 
 It will work using minimum Two Operand

2.1.1)   Arithmetic :-    +,-,*,/,%

2.1.2)  Conditional:-    <,>,<=,>=,!=

2.1.3)  Assignment:-    =,+=,-=,*=,/=

2.1.4)  Logical :-     &&,||,!

2.1.5) Comparison:-    ==,equals()


3) Ternary Operator:-   It is used to solve condition based problem using single line statement


var = (condition)?true:false;


int a=5,b=2;

String s = (a>b)?"a is greater": " b is greater";

Console.WriteLine(s);

   
                                  



Post a Comment

If you have any doubt in programming or join online classes then you can contact us by comment .

Previous Post Next Post