0
String Firstname, Lastname;
Char Gender = 'm';

Console.WriteLine("Cis247a, Week 2 Lab");
Console.WriteLine("Name: Kyle Landell");
Console.WriteLine("This program accepts user input as a string, then makes the" + Environment.NewLine + "appropriate data conversion and assigns the value to Employee objects");
Console.WriteLine("*********Start Program*********" + Environment.NewLine + Environment.NewLine);
Console.WriteLine("*********Prompt for Emplotee information*********" + Environment.NewLine);
Console.WriteLine("Enter the First name: ");
Firstname = Console.ReadLine();
Console.WriteLine("Enter the Last name: ");
Lastname = Console.ReadLine();
Console.WriteLine("Enter the Gender (M or F): ");
Gender.ToString() = Console.ReadLine();
Console.ReadLine();

This is the code I have. I am getting an error with the Gender.ToString() = Console.ReadLine();. The error says I need a variable on the left hand side. Isn't Gender a variable?

Quintin Balsdon
  • 5,484
  • 10
  • 54
  • 95
L. Lawrence
  • 1
  • 1
  • 1
  • You are trying to assign the result of `Gender.ToString()` to `Console.ReadLine()`. You are *not* assigning the input to `Gender`. Either change your definition to be `string Gender = "m";` and then write `Gender = Console.ReadLine()`, or take the first character of `Console.ReadLine()` and store it into `Gender`. For example `Gender = Console.ReadLine()[0]`. – Rob Jan 17 '16 at 05:20

1 Answers1

0

In addition to Rob's comment you can also call

Gender = Console.ReadKey().KeyChar;

to keep the character data type. This will also immediately execute without the need to press 'Enter'.

Bashn
  • 314
  • 1
  • 6