Mini-Projet 1: Gestion des Contacts
Voici un exemple de gestion des contacts en C# :
class Contact {
public string Nom { get; set; }
public string Telephone { get; set; }
public string Email { get; set; }
}
List contacts = new List();
void AjouterContact(string nom, string telephone, string email) {
if (contacts.Any(c => c.Email == email)) {
Console.WriteLine("Erreur: Contact existe déjà!");
return;
}
contacts.Add(new Contact { Nom = nom, Telephone = telephone, Email = email });
Console.WriteLine("Contact ajouté avec succès.");
}
Pas encore de commentaires.
Ajouter un commentaire
Veuillez vous connecter pour ajouter un commentaire.