private void sayHelloButton_Click(object sender, EventArgs e) { var names = nameTextBox.Text; var namesArray = names.Split(' ').Select(n => n.Trim()).Where(n => !string.IsNullOrEmpty(n)).ToArray(); var message = Greeter.FormatGreeting(namesArray); MessageBox.Show(this, message, "Hello", MessageBoxButtons.OK); }
static void Main(string[] args) { var stringToPrint = Greeter.FormatGreeting(args); Console.WriteLine(stringToPrint); }