JungleHeart
New member
- Joined
- Mar 17, 2017
- Messages
- 2
- Programming Experience
- Beginner
Greetings,
I am completely new to programming and also to C#. I'm working out of a book called "Beginning C# 6 Programming with Visual Studio 2015". There is an example that I'm having trouble de-bugging and I swear I have typed everything exactly as in the book! but perhaps I'm missing something... I keep getting the error : Use of unassigned local variable 'firstNumber'
here is the code:
Can someone help??? Thanks in advance!!!
I am completely new to programming and also to C#. I'm working out of a book called "Beginning C# 6 Programming with Visual Studio 2015". There is an example that I'm having trouble de-bugging and I swear I have typed everything exactly as in the book! but perhaps I'm missing something... I keep getting the error : Use of unassigned local variable 'firstNumber'
here is the code:
{ double firstNumber, secondNumber; string userName; Console.WriteLine("Enter your name:"); userName = Console.ReadLine(); Console.WriteLine($"Welcome {userName}!"); Console.WriteLine("Now give me a number:"); secondNumber = Convert.ToDouble(Console.ReadLine()); Console.WriteLine($"The sum of {firstNumber} and {secondNumber} is " + $"{firstNumber + secondNumber}."); Console.WriteLine($"The result of subtracting {secondNumber} from " + $"{firstNumber} is {firstNumber - secondNumber}."); Console.WriteLine($"The result of dividing {firstNumber} by " + $"{secondNumber} is {firstNumber / secondNumber}."); Console.WriteLine($"The remainder after dividing {firstNumber} by " + $"{secondNumber} is {firstNumber % secondNumber}."); Console.ReadKey(); }
Can someone help??? Thanks in advance!!!
Last edited by a moderator: