NSTRUCTIONS In C Keep it all in the Main CS file Problem 1 E

NSTRUCTIONS: In C# (Keep it all in the Main CS file)

Problem #1: Email Checker using String Objects in C#
Create a method that will accept a String as an argument and then check to see if the String follows the pattern of an email address, such as ccc@ddd.eee

You must check the following:
1. Only one @ symbol in the whole string
2. No spaces
3. At least one dot after the @ symbol
4. There is no need to check for .com, .org, etc. 5. The code should work for any string entered.

User Input (Prompt In Main Method, Use As Arguments): o String of an email address

Return Value From Custom Function To Main Method: o “valid” or “invalid”

Result to print to the console in the Main Method:
“The email address of X is a valid email address.” or “The email address of X is not a valid email address.”

Solution

using System;

using System.Collections.Generic;

using System.Text;

using System.Text.RegularExpressions;

namespace Myspace

{

      public class EmailChecker

      {

          public static void Main(string [] args)

         {

          string email,res;

         Console.WriteLine(“Enter email ID: “);

         email= Console.ReadLine();

        res = Emailchecker(string email);

        if (res==”valid);

            MessageBox.show(“The email address of X is a valid email address.”);

      else

           MessageBox.show(“The email address of X is not a valid email address.”);

        }

       private void Emailchecker(string email)

      {

           string format = null;

           format = “^([0-9a-zA-Z] ([-\\\\.\\\\w]*[0-9a-zA-Z]) * @ ( [0-9a-zA-Z] [-\\\\w]* [0-9a-zA-Z]\\\\.) + [a-zA-Z} {2,9})$”;

          if (Regex.IsMatch(email,pattern)

         {

             res = “Valid”;

        }

         else

            res = “Invalid”;

       }

   }

}

NSTRUCTIONS: In C# (Keep it all in the Main CS file) Problem #1: Email Checker using String Objects in C# Create a method that will accept a String as an argume
NSTRUCTIONS: In C# (Keep it all in the Main CS file) Problem #1: Email Checker using String Objects in C# Create a method that will accept a String as an argume

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site