Here I am Posting the program which is one of the most basic as well as important program which
is very important to know every student, that how to code a program which accept multiple value in a same
program by using OR operators.
I have selected the Login system it is one of the best example for understanding the use of OR operator which is denoted by || symbol in program.
In this program here i have also used a label which use in program to take the execution at that place from where we have started the program or even on the place were we need to take the program.
ENJOY CODING!!!!!
_________________________________________________________________________________
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace OR_Operators { class PostSlush { static void Main(string[] args) { string username, password; label: //Creating label at the initial point to restart the program again, which as follows below commands Console.Write("\n\nEnter your login name:\t"); username = Console.ReadLine(); Console.Write("Enter your password:\t"); password = Console.ReadLine(); if ((username == "admin" || username == "administrator") && (password == "admin123"))//here we have use OR operator (||) { Console.WriteLine("\nLogin Successful."); } else { Console.WriteLine("\nInvalid Username OR Password..."); } Console.Write("\n\nPress Y or y for continue.:\t"); char ans = Convert.ToChar(Console.ReadLine()); if (ans == 'Y' || ans == 'y') { goto label; //goto label to start program again. } Console.WriteLine("Press Enter for Exit..."); Console.ReadLine(); } } }
Tags:
csharp.net