C
C#3w ago
tommy

✅ Having trouble going from the old syntax to top level statements

i have been learning C# using the old syntax. i do not know the name for it, but this is what it is:
using System;
class Program
{
public static void Main()
{
Console.WriteLine("Hello, World!");
}
}
using System;
class Program
{
public static void Main()
{
Console.WriteLine("Hello, World!");
}
}
but now that i have started working on Visual Studio, i am having a hard time learning what is the meaning of top level statements. So, how to think about this, considering that i have learnt my basics over Notepad?
7 Replies
leowest
leowest3w ago
No description
leowest
leowest3w ago
that you can simple check that and not use top-level statements and just use the old way which is better anyway.
Salman
Salman3w ago
Use TLS if you don't wanna write Main function always . TLS just allows you to quickly prototype. Nothing more about it. Many people still prefer the old way
tommy
tommyOP3w ago
i too would prefer using the old way but i have to learn top level statements just in case
leowest
leowest3w ago
Top-level statements - programs without Main methods - C#
Learn about top-level statements. You can create programs without the ceremony of a Program class and a Main method.
leowest
leowest3w ago
You absolutely dont need to learn it, it can be helpful in some scenarios where u just want to skip and write code as if u were scripting c# like python etc.
tommy
tommyOP3w ago
okay!!
Want results from more Discord servers?
Add your server