Reputation: 732
I'm following a C#/.NET PluralSight tutorial (building a gradebook) and for some reason, my first 'Console.WriteLine(result)' isn't displaying anything when I use the "Start without Debugging" option. The second Console.WriteLine works fine.
Also, the debugger doesn't work; I set a breakpoint and the debugger runs without stopping and finishes without any errors. I'm working in Visual Studio code. Thoughts?
using System;
namespace GradeBook
{
class Program
{
static void Main(string[] args) //this is a method
{
var numbers = new[] {12.7, 10.3, 6.11, 4.1};
var result = 0.0;
foreach(double number in numbers) {
result += number;
}
Console.WriteLine(result);
if(args.Length > 0) {
Console.WriteLine($"Hello, {args[0]} !");
} else {
Console.WriteLine("Hello!");
}
}
}
}
Upvotes: 0
Views: 65
Reputation: 1
I think you should put Console.ReadLine();
after the if-else statement. There's other way too, but I used to code this line.
Upvotes: 0