0

How to Convert A string to a variable?

Trying to make a user-input calculator, tried myself but came up with too many errors.

22nd Nov 2016, 4:58 PM
Ethan Lajeunesse
Ethan Lajeunesse - avatar
2 Answers
0
Do you mean this? string _UserInput = Console.ReadLine(); Or this? int _UserInputs = Convert.ToInt32(Console.ReadLine());
22nd Nov 2016, 5:40 PM
Andreas BeEm Kvist
Andreas BeEm Kvist - avatar
0
For a user input string use: string variableName = Console.ReadLine(); For a user input integer you need to convert the user input (which is always considered a string) into an integer value using: int variableName = Convert.ToInt32 (Console.ReadLine());
22nd Nov 2016, 10:41 PM
Matthew Tomlin
Matthew Tomlin - avatar