ms_learn_csharp/028_method_parameters/disp_mail_addr/Program.cs

28 lines
843 B
C#
Raw Permalink Normal View History

2024-08-11 14:50:17 -04:00
string[,] corporate = {
{"Robert", "Bavin"}, {"Simon", "Bright"},
{"Kim", "Sinclair"}, {"Aashrita", "Kamath"},
{"Sarah", "Delucchi"}, {"Sinan", "Ali"}
};
string[,] external = {
{"Vinnie", "Ashton"}, {"Cody", "Dysart"},
{"Shay", "Lawrence"}, {"Daren", "Valdes"}
};
const string external_domain = "hayworth.com";
const string internal_domain = "contoso.com";
for (int i = 0; i < corporate.GetLength(0); i++) {
display_email(corporate[i, 0], corporate[i, 1], internal_domain);
}
for (int i = 0; i < external.GetLength(0); i++) {
display_email(external[i, 0], external[i, 1], external_domain);
}
void display_email(string first, string last, string domain=internal_domain) {
string username = first.Substring(0, 2) + last;
username = username.ToLower();
Console.WriteLine($"{username}@{domain}");
}