toplevel-statement Questions
4
Solved
I just started learning c#, I created C# console application. To understand the concepts, I watched videos of how to setup vs code for c#
When I run the dotnet new console command in VS code termin...
Bab asked 7/6, 2022 at 10:29
3
Solved
I recently updated Visual Studio and found out about this new feature (to me it is new) of top-level statements.
As I understand it, the compiler completes the definitions for the Program class and...
Bicorn asked 8/5, 2022 at 11:3
2
Solved
I usually set the attribute [ExcludeFromCodeCoverage] to my Program class, as there are no unit tests for this class possible anyways (or don't make sense either), so it doesn't show up as "mi...
Sales asked 26/4, 2022 at 8:24
1
Solved
I've always been under the assumption that the class generated by Top Level Statements was a hidden, inaccessible class. For example:
System.Console.WriteLine(2);
partial class Program
{
public s...
Custody asked 29/7, 2022 at 15:53
3
So I haven't been coding for long so I'm not so experienced, I recently ran into a problem on replit.com where the console would print out:
error CS8803: Top-level statements must precede namespace...
Dunigan asked 17/10, 2021 at 5:42
2
Using the default WebAPI framework VS2022 in .NET 6. I would like to log information using ILogger, but before the call of "var app = builder.Build();".
Is it possible to retrieve t...
Disgust asked 23/8, 2022 at 23:58
1
Solved
Program1.cs Regular C# file, works perfectly.
Random numberGen = new Random();
int roll1 = 1;
int roll2 = 0;
int roll3 = 0;
int roll4 = 0;
int attempts = 0;
Console.WriteLine("Press enter t...
Sharpie asked 10/4, 2022 at 10:45
1
Solved
I was fiddling with top-level statements as the entry point for a simple console app, since the new .NET 6 template use them as a default.
Yet, as the language specification very clearly states:
N...
Rabbet asked 9/1, 2022 at 20:33
1
© 2022 - 2024 — McMap. All rights reserved.