Posted by : Sudhir Chekuri Wednesday, 30 December 2015

C# Operators are the symbols used in C# programming to performing different types of operations.

They are classified into arithmetic, assignment, unary, relational, logical, bitwise and shift operators.

Lets go in detail about the operators.

C# Arithmetic Operators

C# Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division.

C# Arithmetic operators can be used to perform arithmetic operations between numeric variables values like int, long, float, double, decimal.

C# Arithmetic operators are as follows

+ (addition)

eg: a+b

- (subtraction)

eg: a-b

* (multiplication)

eg: a* b

/ (division)

eg: a/b

% (modulus)

eg: a%b

+ is used as an arithmetic operator if it is used to in between variables of numeric type.

+ is used as concatenation operator to combine two values if it is in between two text datatypes (or) text datatype and numeric datatype.

C# Assignment operators

C# Assignment operators are used to reduce the code.

If you have to write a = a+ b; you can use += assignment operator to reduce that code to a+=b;

Like this we can use below C# Assignment operators to reduce the code as shown in the examples.

+=

Example: a+=b; ie., a=a+b;

-=

Example: a-=b; ie., a=a-b;

*=

Example: a*=b; ie., a=a*b;

/=

Example: a/=b; ie., a=a/b;

%=

Example: a%=b; ie., a=a%b;

C# Increment decrement operators

C# Increment operator is used to increment numeric value by 1 and C# decrement operator is used to decrease numeric value by 1.

Increment and decrement operators looks like this

++ (C# Increment operator)

-- (C# decrement operator)

In increment we have pre increment and post increment.

In decrement we have pre decrement and post decrement.

Preincrement means increasing the value by 1 before the statement gets executed.

Example: ++i

If i is a variable of numeric type containing a value, it will get incremented by 1 before the statement gets executed.

Postincrement means increasing the value by 1 after the statement is executed.

Example: i++

If i is a variable of numeric type containing a value, it will get incremented by 1 after the statement gets executed.

i-- (post decrement)

i is decreased by 1 after the code is executed.

--i (pre decrement) i is decreased by 1 before the code gets executed.

C# Relational operators

C# Relational operators are used to compare two values in variables. Used in if , for and while to check the conditions.

C# Relational operators are as follows

> greater than

< less than

>= greater than or equal to

<= less than or equal to

== equals to

!= not equal to

C# Logical operators

C# Logical operators are logical and, logical or and logical not

&& (logical and) when both are true.

|| (logical or) when one of them is true.

~ (logical not) when both are false.

C# Bit wise operators

& (bitwise and)

| (bitwise or)

^ (bitwise xor)

! (bitwise not)

C# Shift operators

C# Shift operators are used to simply some mathematical operations like multiplication and division operators.

C# Shift left operator works for multiplication. If we write 3<<4 that is equal to 3*2^4.

<< (shift left) (*)

eg: a=3<<4 ie., 3*2^4 =48

C# Shift right operator works for division. If we write 3>>4 that is equal to 3/2^4.

>> (shift right) (/) eg: a=3>>4 ie., 3/2^4 =146

{ 16 comments ... read them below or Comment }

  1. Existing without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
    digital marketing training in annanagar

    digital marketing training in marathahalli

    digital marketing training in rajajinagar

    Digital Marketing online training

    full stack developer training in pune

    ReplyDelete
  2. After reading your post I understood that last week was with full of surprises and happiness for you. Congratz! Even though the website is work related, you can update small events in your life and share your happiness with us too.
    Python training in marathahalli
    AWS Training in chennai

    AWS Training in bangalore

    ReplyDelete
  3. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
    Blueprism online training

    Blue Prism Training in Pune

    Blueprism training in tambaram

    ReplyDelete
  4. Thank you for taking the time to provide us with your valuable information. We strive to provide our candidates with excellent care and we take your comments to heart.As always, we appreciate your confidence and trust in us
    Data Science training in kalyan nagar
    Data Science training in OMR
    selenium training in chennai
    Data Science with Python training in chenni
    Data Science training in chennai
    Data science training in velachery

    ReplyDelete
  5. Thanks a lot for sharing us about this update. Hope you will not get tired on making posts as informative as this. 
    java training in omr | oracle training in chennai

    java training in annanagar | java training in chennai

    ReplyDelete
  6. This information is impressive. I am inspired with your post writing style & how continuously you describe this topic. Eagerly waiting for your new blog keep doing more.
    AWS Training in Chennai
    aws training in bangalore
    AWS Course in Chennai
    aws course in bangalore
    AWS Training centers in Chennai

    ReplyDelete

  7. You write this post very carefully I think, which is easily understandable to me. Not only this, but another post is also good. As a newbie, this info is really helpful for me. Thanks to you.
    Java training in Chennai

    Java Online training in Chennai

    Java Course in Chennai

    Best JAVA Training Institutes in Chennai

    Java training in Bangalore

    Java training in Hyderabad

    Java Training in Coimbatore

    Java Training

    Java Online Training



    ReplyDelete
  8. Title:
    Study Oracle Course in Chennai | Infycle Technologies

    Description:
    Did you want to set your career towards Oracle? Then Infycle is with you to make this into reality. Infycle Technologies gives the combined and best Oracle course in Chennai, which offers various stages of Oracle such as Oracle PL/SQL, Oracle DBA, etc., along with 100% hands-on training guided by experienced trainers in the field. Once after the training, the interviews will be arranged in the MNC's and firms for the placement. To have the Oracle with the best future, call 7502633633 and make this happen for your happy life.

    Top Software training in Chennai

    ReplyDelete
  9. Infycle Technologies, the
    best software training institute in Chennai
    offers the No.1 Python Certification in Chennai for tech professionals. Apart from the Python Course, other courses such as Oracle, Java, Hadoop, Selenium, Android, and iOS Development, Big Data will also be trained with 100% hands-on training. After the completion of training, the students will be sent for placement interviews in the core MNC's. Dial 7502633633 to get more info and a free demo.

    ReplyDelete
  10. Did you want to set your career towards Big Data? Then Infycle is with you to make this into reality. Infycle Technologies gives the combined and best Big Data Hadoop Training in Chennai, in 100% hands-on training guided by specialized trainers in the field. In addition to this, the mock interviews will be given to the candidates, so that they can face the interviews with complete confidence. Apart from all, the candidates will be placed in the top MNC's with a great salary package. To get it all, call 7502633633 and make this happen for your happy life.
    BEST TRAINING IN CHENNAI

    ReplyDelete
  11. Finish the Selenium Training in Chennai from Infycle Technologies, No.1 software training institute in Chennai which is providing professional courses for students, freshers, experienced, and tech professionals. We provide courses like DevOps, Artificial Intelligence, Cyber Security, Python, Oracle, Java, Power BI, Digital Marketing, Data Science, etc. with the best trainers receiving amazing training for the best career. For more details and demo classes call 7504633633.

    ReplyDelete

Followers

Total Pageviews

Powered by Blogger.

Blog Archive

- Copyright © 2013 DevStudent - Metrominimalist - Powered by Blogger - Designed by Johanes Djogan -