C# String Contains Assessment
Question:
Create a complete C# program that will simulate a log-in process. If the username and password are both correct the program will display “Log-in Successful”, otherwise it will display “Invalid Log-in details”
FlowChart:
C# Logical Operators:
Code Answer:
using System;
namespace Module6
{
class module6
{
static void Main(string[] args)
{
string emailid, password;
//use readline get user input
Console.WriteLine("Plz enter u Emaill address :");
emailid = Console.ReadLine();
Console.WriteLine("Plz enter u Password");
password = Console.ReadLine();
//use if else to decision input data contains value
if (emailid.Contains("[email protected]") && (password.Contains("d123456")))
{
Console.WriteLine("Your Log-in Was Successful!");
}
else
{
Console.WriteLine("Invalid Log-in details");
}
Console.ReadLine();
}
}
}
Reference
C# Logical Operators with Examples
https://www.tutlane.com/tutorial/csharp/csharp-logical-operators-with-examples
C# String Contains()
https://www.javatpoint.com/csharp-string-contains