Conditional Logic Example in C#.NET

For making any decisions in the control statements in any programming language we have to use some conditions. for that purpose, we have to use conditional logic statements in the c# language.

For conditional implementation we will use the logical statements.

if we use single &, compiler will check both sides and give answer:
Ex: bool value= true & true;  //result: true

if we use double &&, compiler will check left side, if i.e true it will evaluate left side other wise compiler will terminate from their.
Ex: if(a=="100" && b=="100")
in thie if a!=100 condition checking will stop.

Conditional operators in c#:


OperatorDescription
==for checking both sides equal
!=for checking Not equal to for both sides
<for checking  Less than.
>for checking  Greater than.
<=for checking  Less than or equal to.
>=for checking  Greater than or equal to.
&&for checking  Logical and (evaluates to true only if both expressions are true). If the first expression is false, the second expression is not evaluated.
||for checking  Logical or (evaluates to true if either expression is true). If the first expression is true, the second expression is not evaluated.


Please give your valuable articals on this topic. We will post by the name of you, if you like. Please submit your articles in the comments.

Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar