Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication23
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Type an E-Mail address");
- string Address = Console.ReadLine().ToLower();
- int Valid = 1;
- int Israel=0;
- for (int i = 0; i < Address.Length; ++i)
- {
- if (Address.IndexOf('@') > 0) // בדיקה אם יש שטרודל באימייל
- { }
- else
- { Valid = 0; }
- if (Address.IndexOf('.') == 0||Address.IndexOf('.')<=Address.IndexOf('@')+1) // בדיקה אם יש נקודה, והאם הנקודה באה אחרי השטרודל
- {
- Valid = 0;
- }
- if(Address.Length-1==Address.IndexOf('.')) // בדיקה שיש משהו אחרי הנקודה על ידי בדיקה שהאימייל לא נגמר בנקודה
- {
- Valid=0;
- }
- if(Address.IndexOf(".il")>0) // בודק אם הכתובת ישראלית
- {
- Israel = 1;
- }
- }
- if(Valid==1)
- {
- for (int i = 0; i < Address.IndexOf('@'); ++i) // בדיקת המחרוזת עד השטרודל
- {
- if ((Address[i] >= 'a') && (Address[i] <= 'z')) // בדיקה אם האותיות הן אנגליות
- { }
- else if ((Address[i] >= '0') && (Address[i] <= '9')) // אם לא, בדיקה אם הן מספרים
- { }
- else
- { Valid = 0; } // אם לא, הכתובת לא מתאימה
- }
- for (int i = Address.IndexOf('@')+1; i < Address.IndexOf('.'); ++i) // בדיקת המחרוזת מהשטרודל עד הסיומת
- {
- if ((Address[i] >= 'a') && (Address[i] <= 'z')) // בדיקה אם האותיות הן אנגליות
- { }
- else if ((Address[i] >= '0') && (Address[i] <= '9')) // אם לא, בדיקה אם הן מספרים
- { }
- else
- { Valid = 0; } // אם לא, הכתובת לא מתאימה
- }
- for (int i = Address.IndexOf('.') + 1; i < Address.Length; ++i) // בדיקת הסיומת של האימייל
- {
- if ((Address[i] >= 'a') && (Address[i] <= 'z')) // בדיקה אם האותיות הן אנגליות
- { }
- else if ((Address[i] >= '0') && (Address[i] <= '9')) // אם לא, בדיקה אם הן מספרים
- { }
- else if (Address[i] == '.') // בודק אם יש עוד סיומת לדוגמא co.il
- { }
- else
- { Valid = 0; } // אם לא, הכתובת לא מתאימה
- }
- }
- if (Valid == 1)
- {
- Console.WriteLine("Email is valid");
- if (Israel == 1)
- {
- Console.WriteLine("Email is Israeli");
- }
- }
- else
- {
- Console.WriteLine("Email is invalid");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment