repl.it
@kironroy/

namemethods

C#

C# methods

fork
loading
Files
  • main.cs
  • main.exe
main.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Globalization;

class MainClass {
  public static void Main (string[] args) 
  {
      string firstName = GetUserName(" What is your first name:");
      string firstNameCaps = new CultureInfo("en-US").TextInfo.ToTitleCase(firstName);
      
      string lastName = GetUserName(" What is your last name:");
      string lastNameCaps = new CultureInfo("en-US").TextInfo.ToTitleCase(lastName);

      GreetUser(firstNameCaps, lastNameCaps);

      Console.ReadLine();
  }

  private static string GetUserName(string message)
  {
        Console.WriteLine(message);
        string output = Console.ReadLine();

        return output;
  }
    
  private static void GreetUser(string firstName, string lastName)
  {
      Console.WriteLine($"\nHello {firstName} {lastName}");
  }
}