C# (C Sharp) Console and Input Program

Well, I’ve started a network development class at UVU (UVSC) and I have to quickly learn C Sharp to be able to get my assignments and labs done. Here is my version of the first lab (which is a simple hello world style lab)

 1 using System;
 2 using System.Collections.Generic;
 3 using System.Text;
 4 
 5 namespace Names
 6 {
 7     class Program
 8     {
 9         static void Main(string[] args)
10         {
11             String firstName;
12             String lastName;
13             String fullName;
14 
15             System.Console.Write("Please enter your first name: ");
16             firstName = System.Console.ReadLine();
17 
18             System.Console.Write("Please enter your last name: ");
19             lastName = System.Console.ReadLine();
20 
21             fullName = firstName + " " + lastName;
22             System.Console.WriteLine("your name (first last) is: " + fullName);
23 
24             fullName = lastName + ", " + firstName;
25             System.Console.WriteLine("your name (last, first) is: " + fullName);
26 
27             System.Console.ReadLine();
28         }
29     }
30 }

Leave a Reply


Switch to our mobile site