sandcounter
New member
- Joined
- Oct 6, 2015
- Messages
- 3
- Programming Experience
- Beginner
Hello all: I'm new to coding and this forum, using c# visual studio 2012. I am trying to get this code to read the user input and read it on a separate line. I get an un-handled exception, not sure why. Thank You
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Lesson_5_Project { class EmpApp { static void Main() { char last; DisplayInstructions(); last = GetName("Last:"); DisplayName(last); // Object: myEmployee Employee myEmployee = new Employee(); // Instantiate the object myEmployee.GetPaySchedule(); Console.ReadLine(); } public static void DisplayInstructions() { Console.WriteLine("This program will calculate the employee's take-home pay."); /*Console.Write("Enter Last name: {0}", last); Console.ReadKey();*/ } public static char GetName(string name1) { string inValue; char Name; Console.Write("Enter {0}", name1); inValue = Console.ReadLine(); Name = char.Parse(inValue);/*An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll Additional information: String must be exactly one character long.*/ return Name; } public static void DisplayName(char last) { Console.WriteLine("Last Name: {0}", last); } } }