Recap - Validation Function
Part of the Fundamentals section of Coddy's C# journey — lesson 53 of 69.
Challenge
EasyWrite a method named is_valid that gets two strings arguments, username and password.
The method will return True if the username and password are valid in the system, otherwise False.
Our system contains only two valid usernames - "admin" and "user".
The valid password for username "user" is "qweasd".
For username "admin" any password is valid!
Try it yourself
using System;
public class Program {
public static bool is_valid(string username, string password) {
// Write your code below
}
public static void Main(string[] args) {
string user = Console.ReadLine();
string pass = Console.ReadLine();
bool res = is_valid(user, pass);
Console.WriteLine(res);
}
}All lessons in Fundamentals
4Operators Part 1
Arithmetic OperatorsModulo OperatorIncrement/DecrementPost Increment/DecrementArithmetic Shortcuts10Methods (Functions)
Declaring MethodsMethod ParametersReturn TypesOptional ParametersRecap - Validation FunctionVoid Methods5Operators Part 2
Comparison OperatorsLogical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3