using System.ComponentModel.DataAnnotations; using System.Net.Mail; namespace ContactsApp { public class Contact { public Guid Id { get; } public string Name { get; set; } public string? Email { get; set; } public string Phone { get; set; } public Contact(string name, string? email, string phone) { Id = Guid.NewGuid(); Name = name; try { var addr = new MailAddress(email); Email = email; } catch (Exception ex) { throw new Exception("Invalid email"); } Phone = phone; } } }