Questions tagged [toplevel-statement]

C# 9 introduces top-level statements which let to write programs with less boilerplate code.

18 questions
0
votes
2 answers

Checking in C# whether MySQL database exists

I'm writing a simple console application in C# using top-level statements, and I want to check at the beginning whethere there exists a database. Here's my code: using MySql.Data.MySqlClient; using (MySqlConnection connection = new…
0
votes
0 answers

How to fix top-level-statement error in creating http3 sample project

I'm creating a sample C# environment for http3 in .net 6 I'm following this blog but I'm getting this error: Error CS8802 Only one compilation unit can have top-level statements. Here is my Program.cs code which in Server project it is showing…
haris
  • 1
  • 1
0
votes
1 answer

Top level statements: live code suggestion not working?

I saw a new feature, the Top level statements that simplifies the entry point of a console application In Microsoft Docs Yet one simple thing I am not able to get sugestions for: Using for namespaces outside this project After adding the references…
1
2